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
What is basename php?
Are react hooks stable?
Can you explain, when to use if-else if-else over switch statements?
What is prepare in php?
How do I use isdigit function?
Tell me how is it possible to return a value from a function?
Which functions are used to count the total number of array elements in php?
What are the difference between abstract class and interface in oops?
Which function is used in php to delete a file?
What is $_ server request_method == post?
How many php functions are there?
What enctype is required for file uploads to work?
What is difference between readonly and constant?
what is session_set_save_handler in PHP?
what is difference between PHP4 , PHP5