[SOLVED] Does a value exist in an array?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
webcan
Forum Commoner
Posts: 66
Joined: Tue Oct 28, 2003 2:25 pm
Location: Toronto, Canada

Does a value exist in an array?

Post by webcan »

Hey guys ...

I have an array, $thistemp, which has values, 1, 3, 5, 6, 12, 15, 19, 22.

I also have a loop which goes through a bunch of numbers, and I want it to check on each number whether that number exists as a value in $thistemp.

I tried this with isset and array_key_exists, but I can't get it to work.

If I do var_dump(isset($thistemp['5'])) for example, it comes back false.

Any ideas?

Thanks,
Peter.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

[php_man]in_array[/php_man]
webcan
Forum Commoner
Posts: 66
Joined: Tue Oct 28, 2003 2:25 pm
Location: Toronto, Canada

Post by webcan »

Sweet - thanks!
Post Reply