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 array filter php?
> symbol is used to redirect the output of a command. State Whether True or False?
What is the use of Php variables?
How to create a session? How to set a value in session? How to remove data from a session?
How to increase the maximum execution time of a script in php?
How to write php function in html onclick?
Explain difference between urlencode and urldecode?
How to write a program to make chess?
What are the Formatting and Printing Strings available in PHP?
Do you know what is the function mysql_pconnect() usefull for?
What is dao in php?
What is framework in php for beginners?
What is default session time and path in php?
How can we encrypt the password using php?
What is session and Cokkies . How it works . tell some thing about Session_id()