Sunday, November 3, 2013

[PHP] in_array() function

in_array() function, is for checking is the keyword you want in the array or not.

<?php$people = array("Peter", "Joe", "Glenn", "Cleveland");
if (in_array("Glenn", $people))  {  echo "Match found";  }else  {  echo "Match not found";  }?>
This example is for search the keyword "Glenn" with the array named $people.


Reference:
http://us2.php.net/in_array
http://www.w3schools.com/php/func_array_in_array.asp

No comments :

Post a Comment