After getting a very good response on my earlier compilation “Basic Questions on PHP “, I am back with a new compilation of basic PHP questions on arrays.
1- How to check if a value exists in an array?
Ans- Use in_array() function for this.
Example:
<?php
$sample = array(“banana”,”apple”,”pear”,”banana”);
$newvalue = “pear”;
if (in_array($newvalue,$sample)) { echo “$newvalue is already in the array!”; [...]
Archive for November 16th, 2009
Basic Questions on PHP Part2
Posted in PHP, tagged PHP, PHP Interview, Web Technology on November 16, 2009 | Leave a Comment »