How can I check if a value is already in an array?

Answer Posted / mohammed khalid khan

The first answer is not complete.
&
The second answer is correct.


<?php
$values = array("banana","apple","pear","banana");
if (in_array("pear",$values))
{
echo "Got pear";
}
?>

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is trait in php?

546


Write a program to get lcm of two numbers using php?

512


if you run the app program all vendor open items are cleared but is it possible to reverse the again again open items please tell me the answer

1279


What is the difference between $name and $$name?

529


What are majic methords in php?

585






How to receive a cookie from the browser?

563


How is it possible to know the number of rows returned in result set?

531


How a constant is defined in a php script?

572


How does php session work?

524


Is learning php easy?

529


So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?

556


What is list in PHP?

648


What is api used for?

489


Should I learn php before wordpress?

500


How to swap two variables without using 3rd temp variable.

497