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 are default session time and path?
How do you display the output directly to the browser?
Will react hooks replace redux?
Which is the best php framework for a beginner?
Explain what is the difference between session and cookie?
How is a session id generated?
What is the scope of a variable defined outside a function?
What is c++ polymorphism?
What is the default time of cookie in php?
What is escape data in php?
What is $globals php?
What is the use of ajax in php?
Tell me how can we get the error when there is a problem to upload a file?
Explain the types of functions for Splitting String?
What is difference between isset and empty in php?