Select an option to see the answer and solution.
Arrays
practice.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
53
Questions
1/3
Page
Pick an option on a question to see the right answer and solution.
1. state[0] = “karnataka”;
2. $state[] = array(“karnataka”);
3. $state[0] = “karnataka”;
4. $state = array(“karnataka”);
Select an option to see the answer and solution.
<?php
$states = array("karnataka" => array( "population" => "11,35,000", "captial" => "Bangalore"),"Tamil Nadu" => array( "population" => "17,90,000","captial" => "Chennai") );
echo $states["karnataka"]["population"];
?>Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
<?php
$state = array ("Karnataka", "Goa", "Tamil Nadu", "Andhra Pradesh");
echo (array_search ("Tamil Nadu", $state) );
?>
Select an option to see the answer and solution.
<?php
$fruits = array ("apple", "orange", "banana");
echo (next($fruits));
echo (next($fruits));
?>
Select an option to see the answer and solution.
Select an option to see the answer and solution.
<?php
$fruits = array ("apple", "orange", array ("pear", "mango"), "banana");
echo (count($fruits, 1));
?>
Select an option to see the answer and solution.
Select an option to see the answer and solution.
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . cars[1] . " and " . $cars[0] . ".";
?>
Select an option to see the answer and solution.
<?php
$fname = array("Peter", "Ben", "Joe");
$age = array("35", "37", "43");
age, $fname);
print_r($c);
?>
Select an option to see the answer and solution.
<?php
$a=array("A","Cat","Dog","A","Dog");
$b=array("A","A","Cat","A","Tiger");
a,$b);
print_r(array_count_values($c));
?>
Select an option to see the answer and solution.
<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
$a2 = array("e" => "red", "f" => "green", "g" => "blue", "h" => "orange");
$a3 = array("i" => "orange");
a2, $a3);
a4, $a2);
print_r($result);
?>
Select an option to see the answer and solution.
<?php
$a1 = array("red", "green");
$a2 = array("blue", "yellow");
a1, $a2);
$a4 = array("a", "b", "c", "d");
a4, $a3);
print_r($a);
?>
Select an option to see the answer and solution.
<?php
$names = array("Sam", "Bob", "Jack");
echo names[1] . " and " . $names[1] . ".";
?>
Select an option to see the answer and solution.
<?php
$names = array("Sam", "Bob", "Jack");
echo names[1] . " and " . brother;
?>
Select an option to see the answer and solution.
<?php
$place = array("NYC", "LA", "Paris");
array_pop($place);
$place1 = array("Paris");
place, $place1);
print_r($place);
?>
Select an option to see the answer and solution.
<?php
$age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");
array_change_key_case($age, CASE_UPPER);
array_pop($age);
print_r($age);
?>Select an option to see the answer and solution.
<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
a1);
print_r($result);
?>Select an option to see the answer and solution.