Pages

Saturday, 22 June 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";
}
?>

No comments:

Post a Comment