2. Which of the following are correct ways of creating an array?
1. state[0] = “karnataka”;
2. $state[] = array(“karnataka”);
3. $state[0] = “karnataka”;
4. $state = array(“karnataka”);
1. state[0] = “karnataka”;
2. $state[] = array(“karnataka”);
3. $state[0] = “karnataka”;
4. $state = array(“karnataka”);
3. What will be the output of the following php code?
<?php
$states = array("karnataka" => array( "population" => "11,35,000", "captial" => "Bangalore"),"Tamil Nadu" => array( "population" => "17,90,000","captial" => "Chennai") );
echo $states["karnataka"]["population"];
?>
<?php
$states = array("karnataka" => array( "population" => "11,35,000", "captial" => "Bangalore"),"Tamil Nadu" => array( "population" => "17,90,000","captial" => "Chennai") );
echo $states["karnataka"]["population"];
?>
4. Which function will return true if a variable is an array or false if it is not?
5. Which in-built function will add a value to the end of an array?
6. 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) );
?>
<?php
$state = array ("Karnataka", "Goa", "Tamil Nadu", "Andhra Pradesh");
echo (array_search ("Tamil Nadu", $state) );
?>
7. What will be the output of the following PHP code?
<?php
$fruits = array ("apple", "orange", "banana");
echo (next($fruits));
echo (next($fruits));
?>
<?php
$fruits = array ("apple", "orange", "banana");
echo (next($fruits));
echo (next($fruits));
?>
8. Which function can be used to move the pointer to the previous array position?
9. What will be the output of the following PHP code?
<?php
$fruits = array ("apple", "orange", array ("pear", "mango"), "banana");
echo (count($fruits, 1));
?>
<?php
$fruits = array ("apple", "orange", array ("pear", "mango"), "banana");
echo (count($fruits, 1));
?>