je cherche à tester si la clé correspond à la valeur avec la fonction array_search();
Mais mon test ne fonctionne pas, j'avoue non plus ne pas comprendre le prototype:
Code : Tout sélectionner
mixed array_search ( mixed needle, array haystack [, bool strict] )$image = 'img src="11"';
$chemin=array($image);
if(TRUE === array_search($image, $chemin)) {
array_push ($chemin, 'img src="22"');
}
foreach($chemin as $val) {
echo $val.'<br>';
}
Merciedit
in_array fait l'affaire
if(in_array($image, $chemin)) {
array_push ($chemin, 'img src="22"');
}