Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

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”];
?>

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”];
?>
a) Karnataka 11,35,000
b) 11,35,000
c) population 11,35,000
d) Karnataka population

Answer: b
Explanation: In the following PHP code, the variable states are treated as a multidimensional array and accordingly traverse it to get the value of ‘Karnataka’s population’.

Join The Discussion