How can I check if a value is already in an array?
Answer Posted / deep
The above answer is correct. I will just add a complete
example.
<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os))
{
echo "Got Irix";
}
if (in_array("mac", $os))
{
echo "Got mac";
}
?>
| Is This Answer Correct ? | 7 Yes | 2 No |
Post New Answer View All Answers
What is php.ini & .htacess file?
How to register a variable in PHP session?
How can we display information of a variable and readable by human with php?
How can we pass the variable through the navigation between the pages?
What are the different types of array in php?
Write a php function to convert all null values to blank?
What is zend studio for?
What is a string in r?
Which is better get or post method?
How is php different from other languages?
How to execute a function in php?
How to get elements in reverse order of an array in php?
What is the use of mysql_fetch_assoc in php?
What is the difference between null and empty?
How we can retrieve the data in the result set of mysql using php?