Tuesday, July 10, 2012

PHP: find key into array


Use the in_array() method:


$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
    echo "Got Irix";
}
if (in_array("mac", $os)) {
    echo "Got mac";
}

Resource:
http://php.net/manual/en/function.in-array.php

No comments: