What will be the output of the following PHP code?
<?php
$state = array (“Karnataka”, “Goa”, “Tamil Nadu”,
“Andhra Pradesh”);
echo (array_search (“Tamil Nadu”, $state) );
?>
a) True
b) 1
c) False
d) 2
Answer: d
Explanation: The array_search() function searches an array for a specified value, returning its key if located and FALSE otherwise.
Related Posts
Which function returns an array consisting of associative key/value pairs?
What will be the output of the following PHP code?
<?php
$fruits = array (“apple”, “orange”, array (“pear”, “mango”),
“banana”);
echo (count($fruits, 1));
?>Which of the following function is used to get the value of the previous element in an array?
What will be the output of the following PHP code?
<?php
$fruits = array (“apple”, “orange”, “banana”);
echo (next($fruits));
echo (next($fruits));
?>Which in-built function will add a value to the end of an array?
Which of the following PHP function will return true if a variable is an array or false if it is not an array?
What will be the output of the following PHP code?
<?php
$states = array(“Karnataka” => array
(“population” => “11,35,000”, “capital” => “Bangalore”),
“Tamil Nadu” => array( “population” => “17,90,000”,
“capital” => “Chennai”) );
echo $states[“Karnataka”][“population”];
?>
Join The Discussion