array multidimensionnel : supprimer une entrée
Bonjour,
Je sèche, sans comprendre ce qui cloche.
J'ai 2 arrays :
Code:
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
| $foo =
array (size=436)
0 =>
array (size=3)
'id' => string '2459' (length=4)
'prenom' => string 'bird' (length=4)
'nom' => string 'Jean' (length=4)
1 =>
array (size=3)
'id' => string '2444' (length=4)
'prenom' => string 'Luc' (length=3)
'nom' => string 'CestPasMoi' (length=10)
2 =>
array (size=3)
'id' => string '2474' (length=4)
'prenom' => string 'Steph' (length=5)
'nom' => string 'CestMoi' (length=7)
3 =>
array (size=3)
'id' => string '2446' (length=4)
'prenom' => string 'Rasta' (length=5)
'nom' => string 'CestLui' (length=6)
4 =>
array (size=3)
'id' => string '2537' (length=4)
'prenom' => string 'Thia' (length=4)
'nom' => string 'CestElle' (length=8)
$bar =
array (size=8)
0 =>
array (size=2)
'idCherche' => string '8' (length=1)
'idUneAutre' => string '2459' (length=4)
1 =>
array (size=2)
'idCherche' => string '8' (length=1)
'idUneAutre' => string '2474' (length=4)
2 =>
array (size=2)
'idCherche' => string '8' (length=1)
'idUneAutre' => string '2537' (length=4) |
Dans $foo['id'], je voudrai supprimer les entrées qui correspondent à celles qui sont dans $bar['idUneAutre'].
J'ai donc fait un truc comme ça :
Code:
1 2 3 4 5 6 7 8 9
| foreach($foo as $unFoo) {
foreach($bar as $leBar) {
if ($bar['idUneAutre'] == $foo['id']) {
unset($unFoo, $foo);
}
}
}
return $foo; |
Mais ça ne fonctionne pas :calim2: Wamp me répond
Citation:
Undefined variable: unFoo in c:\blablabla on line 145
ça ne fonctionne pas comme ça unset ?
où c'est autre chose ?
D'avance merci pour vos éclairages :)