bonjour a tous!

voila, j'essaye de classer mon tableau $rows
:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
//j'ai fais un print_r
 
Array
(
    [0] => Array
        (
            [0] => 38
            [produit_id] => 38
            [1] => 1255609053.jpg
            [photo] => 1255609053.jpg
            [2] => 00155
            [reference_client] => 00155
            [3] => 
            [nom] => 
            [4] => Ramette papier A4
            [designation] => Ramette papier A4
            [5] => Famille 1
            [famille] => Famille 1
            [6] => Sous-famille 1
            [sous_famille] => Sous-famille 1
 
        )
 
    [1] => Array
        (
            [0] => 32
            [produit_id] => 32
            [1] => 1255085963.jpg
            [photo] => 1255085963.jpg
            [2] => sdgfsfdsdddddd
            [reference_client] => sdgfsfdsdddddd
            [3] => 
            [nom] => 
            [4] => d
            [designation] => d
            [5] => Famille 1
            [famille] => Famille 1
            [6] => Sous-famille 1
            [sous_famille] => Sous-famille 1
 
        )
 
    [2] => Array
        (
            [0] => 34
            [produit_id] => 34
            [1] => 1255424682.jpg
            [photo] => 1255424682.jpg
            [2] => qsfd
            [reference_client] => qsfd
            [3] => 
            [nom] => 
            [4] => 
            [designation] => 
            [5] => nouvelle famille +1
            [famille] => nouvelle famille +1
            [6] => nvl sous famille +2
            [sous_famille] => nvl sous famille +2
 
        )
 
    [3] => Array
        (
            [0] => 38
            [produit_id] => 38
            [1] => 
            [photo] => 
            [2] => 
            [reference_client] => 
            [3] => 
            [nom] => 
            [4] => 
            [designation] => 
            [5] => 
            [famille] => 
            [6] => 
            [sous_famille] => 
 
        )
 
    [4] => Array
        (
            [0] => 39
            [produit_id] => 39
            [1] => 
            [photo] => 
            [2] => 
            [reference_client] => 
            [3] => 
            [nom] => 
            [4] => 
            [designation] => 
            [5] => 
            [famille] => 
            [6] => 
            [sous_famille] => 
 
        )
 
    [5] => Array
        (
            [0] => 50
            [produit_id] => 50
            [1] => 
            [photo] => 
            [2] => 
            [reference_client] => 
            [3] => 
            [nom] => 
            [4] => 
            [designation] => 
            [5] => 
            [famille] => 
            [6] => 
            [sous_famille] => 
 
 
        )
 
)
par ordre de 'produit_id'

j'utilise pour se faire la fonction usort() :



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
$b='produit_id';
function compare($rows, $b) 
{
    if ($rows == $b) {
      return 0;
    }
    return ($rows > $b) ? -1 : 1;
}
 
 
usort($rows, "compare");
 
foreach ($rows as $key => $value) {
    echo $key.':'.$value[$b].'</br>';
}


sauf que ca m'affiche :


0:38
1:50
2:39
3:38
4:34
5:32


s'pas du tout trié!

quoi qu'ai-je mal fais siouplais?
merci!