Answer Posted / sivanandareddy
The array_search() function search an array for a value and returns the key.
Syntax:..array_search(value,array,strict)
Parameter Description
value Required. Specifies the value to search for
array Required. Specifies the array to search in
strict Optional. Possible values:
true
false - Default
When set to true, the number 5 is not the same as the string 5 (See example 2)
Example 1
<?php
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
echo array_search("Dog",$a);
?>
The output of the code above will be:
a
Example 2
<?php
$a=array("a"=>"5","b"=>5,"c"=>"5");
echo array_search(5,$a,true);
?>
The output of the code above will be:
b
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is mean tnq
What is the difference between array_merge() and array_merge_recursive() in php?
Tell me in php, objects are they passed by value or by reference?
What is the array in php?
Which is the correct way to check if a session has already been started ?
How to count a number of words in a string in php?
How long does a session last in php?
What is use of isset function in php?
What is the use of inner join in mysql?
Who is known as the father of php?
What is php's mysqli extension?
What is the $_ server php_self variable?
How to return ascii value of character in php?
Is apache needed for php?
Which is used to maintain the value of a variable over different pages?