Q.1
Assume you would like to sort an array in ascending order by value while preserving key associations. Which of the following PHP sorting functions would you use?
Q.2
What will be the output of the following PHP code?
<?php
$cars = array("Volvo", "BMW", "Toyota", "Honda", "Mercedes", "Opel");
print_r(array_chunk($cars, 2));
?>
Q.3
What will be the output of the following PHP code?
<?php
$fname = array("Peter", "Ben", "Joe");
$age = array("35", "37", "43");
$c = array_combine($fname, $age);
print_r($c);
?>
Q.4
What will be the output of the following PHP code?
<?php
$a = array("a"=>"red", "b"=>"green", "c"=>"blue");
echo array_shift($a);
print_r ($a);
?>
Q.5
What will be the output of the following PHP code?
<?php
$arr = array ("picture1.JPG", "picture2.jpg", "Picture10.jpg", "picture20.jpg");
sort($arr);
print_r($arr);
?>
Q.6
What will be the output of the following PHP code?
<?php
$face = array ("A", "J", "Q", "K");
$number = array ("2","3","4", "5", "6", "7", "8", "9", "10");
$cards = array_merge ($face, $number);
print_r ($cards);
?>
Q.7
What will be the output of the following PHP code ?
<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
$a2 = array("e" => "red","f" => "green", "g" => "blue");
$result = array_intersect($a1, $a2);
print_r($result);
?>
Q.8
What will be the output of the following PHP code ?
<?php
$a = array(12, 5, 2);
echo(array_product($a));
?>
Q.9
What will be the output of the following PHP code?
<?php
$a = array("red", "green", "blue");
array_pop($a);
print_r($a);
?>
Q.10
What will be the output of the following PHP code?
<?php
$fruits = array ("apple", "mango", "peach", "pear", "orange");
$subset = array_slice ($fruits, 2);
print_r ($subset);
?>
Q.11
What will be the output of the following PHP code?
<?php
$names = array("Sam", "Bob", "Jack");
echo $names[0] . "is the brother of " . $names[1] . " and " . $names[1] . ".";
?>
Q.12
What will be the output of the following PHP code?
<?php
$names = array("Sam", "Bob", "Jack");
echo $names[0] . "is the brother of " . $names[1] . " and " . $names[1] . ".".$brother;
?>
Q.13
What will be the output of the following PHP code ?
<?php
$a = array("a" => "Jaguar", "b" => "Land Rover", "c" => "Audi", "d" => "Maseratti");
echo array_search("Audi", $a);
?>
Q.14
What will be the output of the following PHP code ?
<?php
$city_west = array("NYC", "London");
$city_east = array("Mumbai", "Beijing");
print_r(array_replace($city_west, $city_east));
?>
Q.15
What will be the output of the following PHP code?
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[2] . ", " . $cars[1] . " and " . $cars[0] . ".";
?>
Q.16
What will be the output of the following PHP code?
<?php
$fname = array("Peter", "Ben", "Joe");
$age = array("35", "37", "43");
$c = array_combine($age, $fname);
print_r($c);
?>
Q.17
What will be the output of the following PHP code?
<?php
$place = array("NYC", "LA", "Paris");
array_pop($place);
$place1 = array("Paris");
$place = array_merge($place, $place1);
print_r($place);
?>
Q.18
What will be the output of the following PHP code ?
<?php
$age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");
array_change_key_case($age, CASE_UPPER);
array_pop($age);
print_r($age);
?>
Q.19
What will be the output of the following PHP code ?
<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
$result = array_flip($a1);
print_r($result);
?>
Q.20
What will be the output of the following PHP code ?
<?php
$people = array("Peter", "Susan", "Edmund", "Lucy");
echo pos($people);
?>
0 h : 0 m : 1 s