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

How to submit form without a submit button.

513


Is php faster than javascript?

489


What is scope of variable in php?

555


What are default session time and path?

539


Define object-oriented methodology?

553






What is the difference between rest and soap?

548


How can you create a session in php?

508


What is encapsulation in php?

538


explain php variable length argument function.

555


How does php strcmp work?

486


How do you count numbers in php?

477


what is constructor

1045


What are different types of errors available in Php?

481


How can we execute a php script using command line?

498


What is php limit?

498