PDA

View Full Version : PHP: check array?



Ubuntuud
May 3rd, 2007, 01:29 PM
Hi,
Is there a way to check if a variable exists in an array, like:


$my_array = array('apple');

if ('apple' in $my_array) {
do_this();
} else {
do_that();
}

Is this possible?

Thanks in advance,
pieter.

Mirrorball
May 3rd, 2007, 01:51 PM
http://www.php.net/manual/en/function.in-array.php

Ubuntuud
May 3rd, 2007, 01:52 PM
:D
Thanks alot!