|
Posted by J.O. Aho on 03/07/06 13:49
Gernot Frisch wrote:
> $arr = split(' ', 'Kung Fu Fighting');
>
> if (is_inside_array($arr, 'Fu') )
> ...
>
>
> how do I program something like that? Checking if a value is inside
> the array?
$arr = split(' ', 'Kung Fu Fighting');
if(in_array("Fu",$arr)) {
echo "The word 'Fu' is in the array $arr!!!\n";
} else {
echo "Didn't find the word 'Fu' in the array $arr.\n");
}
> I tried: isset($arr['Fu']), but it returns nothing...
This will look for the key 'Fu' in the array $arr and see if it has been set
or not, has nothing to do with the data "Fu" that you are looking for. Your
array has only the keys 0,1 and 2, so 'Fu' is unset which results in false.
//Aho
Navigation:
[Reply to this message]
|