Pages

Showing posts with label in_array. Show all posts
Showing posts with label in_array. Show all posts

22 Jun 2013

php in_array function

in_arrayChecks if a value exists in an array

bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )



Example #1 in_array() example
<?php
$os 
= array("Mac""NT""Irix""Linux");
if (
in_array("Irix"$os)) {
    echo 
"Got Irix";
}
if (
in_array("mac"$os)) {
    echo 
"Got mac";
}
?>