You are here: Re: is element in array? « All PHP « IT news, forums, messages
Re: is element in array?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация