I have 2 arrays merge to one array now i want to check if value 1 in array $s then display value in for each only from $s array but in above example display the value from $b and $b how can i get the value from $s only by using if() sorry about my English :(
$s = array(1,2,3,4,5);
$b = array(1,2,3,4);
$one = array_merge($s,$b);
foreach($one as $k=>$v){
if(in_array(1,$s)){
// display only value from array $s
echo $v;
}
if(in_array(1,$b)){
// display only value from array $b
echo $b;
}
}
Aucun commentaire:
Enregistrer un commentaire