Key/value pair can be initialized using = operator?
1. True
2.False
3.Depend on program
4.Keys does not exist in array
PHP’s numerically indexed array begin with position ___________
1.1
2.2
3.0
4. -1
Predict the output of the following code. <?php $a=array(1,2,3,5,6); next($a); next($a); next($a); echo current($a); ?>
1.2
2.3
3.4
4.5
Predict the output of the following PHP code. <?php $fruits = array ("apple", "orange", "banana", "guava", "pine-apple", "papaya", "melon"); next($fruits); next($fruits); prev($fruits); ?>
1.guava
2.banana
3.orange
4.pine-apple
What is the use of array_unshift() function?
1.Function is used to print the array in readable format.
2. Adds elements to the beginning of the array and returns the size of array
3.Function can be used to verify if a variable is an array. Returns TRUE or FALSE
4.Adds elements to the end of the array and returns the size of array.
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); ?>
1.Array ( [0] => A [1] => J [2] => Q [3] => K [4] => 2 [5] => 3 [6] => 4 [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11] => 9 [12] => 10 )
2.Array ( [0] => A [1] => 2 [2] => J [3] => 3 [4] => Q [5] => 4 [6] => K [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11] => 9 [12] => 10 )
3.Error
4.Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 [7] => 9 [8] => 10 [9] => A [10] => J [11] => Q [12] => K )
What will be the output of the following PHP code? <?php $fruits = array ("apple", "orange", array ("pear", "mango"), "banana"); echo (count($fruits, 1)); ?>
1.3
2.4
3.5
4.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) ); ?>
1. True
2.1
3.False
4.2
What will be the output of the following PHP code? <?php $a = array("A", "Cat", "Dog", "A", "Dog"); print_r(array_count_values($a)); ?>
1.Array ( [A] => 2 [Cat] => 1 [Dog] => 2 )
2. Array ( [A] => 2 [Cat] => 2 [Dog] => 1 )
3.Array ( [A] => 1 [Cat] => 1 [Dog] => 2 )
4.Array ( [A] => 2 [Cat] => 1 [Dog] => 1)
What will be the output of the following PHP code? <?php $a = array("red", "green", "blue"); array_pop($a); print_r($a); ?>
1.Array ( [0] => red [1] => green )
2.Array ( [0] => green [1] => blue )
3. Array ( [0] => red [1] => blue )
4.Array ( [0] => blue [1] => blue )
What will be the output of the following PHP code? <?php $a1 = array("red", "green"); $a2 = array("blue", "yellow"); $a3 = array_merge($a1, $a2); $a4 = array("a", "b", "c", "d"); $a = array_combine($a4, $a3); print_r($a); ?>
1.Array ( [a] => blue [b] => yellow [c] => red [d] => green )
2.Array ( [0] => blue [1] => yellow [2] => red [3] => green )
3.Array ( [0] => red [1] => green [2] => blue [3] => yellow )
4.Array ( [a] => red [b] => green [c] => blue [d] => yellow )
What will be the output of the following PHP code? <?php $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43"); print_r(array_change_key_case($age, CASE_UPPER)); ?>
1. a) Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
2.Array ( [peter] => 35 [ben] => 37 [joe] => 43 )
3.Array ( [PETER] => 35 [BEN] => 37 [JOE] => 43 )
4.Array ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 )
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] . "."; ?>
1. I like Volvo, Toyota and BMW
2. I like Volvo, BMW and Toyota
3.I like BMW, Volvo and Toyota
4.I like Toyota, BMW and Volvo
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)); ?>
1.Array ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] => Honda ) [2] => Array ( [1] => Mercedes [2] => Opel ) )
2.Array ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] => Honda ) [3] => Array ( [1] => Mercedes [2] => Opel ) )
3.Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array ( [0] => Toyota [1] => Toyota ) )
4.Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) )
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); ?>
1.Array ( Peter Ben Joe )
2. Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
3. Array ( 35 37 43 )
4.Array ( “[Peter] => 35†“[Ben] => 37†“[Joe] => 43†)
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] . "."; ?>
1.Sam is the brother of Bob and Jack
2.Samis the brother of Bob and Bob
3.Sam is the brother of Jack and Bob
4.Error
Which in-built function will add a value to the end of an array?
1.array_unshift()
2.into_array()
3.inend_array()
4.array_push()
Which in-built function will add a value to the end of an array?
1. array_unshift()
2. into_array()
3.inend_array()
4. array_push()
Which of the following are correct ways of creating an array? i) state[0] = "karnataka"; ii) $state[] = array("karnataka"); iii) $state[0] = "karnataka"; iv) $state = array("karnataka");
1. iii) and iv)
2. ii) and iii)
3.Only i)
4.ii), iii) and iv)
A ________ is an array with more than two dimensions.
1. A. single dimensional array
2.multi dimensional array
3.Both A and B
4.None of the above
As compared to associative arrays vector arrays are much
1.Faster
2.Slower
3.Stable
4.None of the above
By default, the index of array in php starts from ______?
1. 0
2.1
3.-1
4.2
What is the output of the following php code? <?php $alphabet = array("A" => array ( "php" => "php 7.0", "date" => "3 December 2019"), "B" => array( "python" => "python 3.8.2", "date" => "24 December 2019") ); echo $alphabet ["A"]["date"]; ?>
1. php 7.0
2. 3 December 2019
3. python 3.8.2
4.24 December 2019
What is the output of the following php code? <?php $alphabet = array ("A", "B", "C"); echo (next($alphabet)); ?>
1.A
2.B
3.C
4.Error
What is the use of array_flip() function?
1.Rearranges the array elements in the reverse order
2.Is used to convert the keys to values and values to keys.
3.Can be used to fetch the keys present in the array
4.Returns number of elements in the array
What is the use of array_values() function?
1.Returns all the values of the respective keys present in the passed array
2.Returns number of elements in the array
3.Can be used to fetch the keys present in the array
4. Returns the values and the frequency of each value in form of an array.
What is the use of is_array() function?
1.Function is used to print the array in readable format.
2.Adds elements to the beginning of the array and returns the size of array.
3.Function can be used to verify if a variable is an array. Returns TRUE or FALSE
4.Adds elements to the end of the array and returns the size of array.
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); ?>
1.Array ( [0] => picture1.JPG [1] => Picture10.jpg [2] => picture2.jpg [3] => picture20.jpg )
2. Array ( [0] => picture1.JPG [1] => picture2.jpg [2] => Picture10.jpg [3] => picture20.jpg )
3.Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture2.jpg [3] => picture20.jpg )
4.Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture20.jpg [3] => picture2.jpg )
What will be the output of the following PHP code? <?php $array1 = array ("KA", "LA", "CA", "MA", "TA"); $array2 = array ("KA", "IA", "CA", "GA", "TA"); $inter = array_intersect ($array1, $array2); print_r ($inter); ?>
1.Array ( [0] => KA [1] => LA [2] => CA [3] => MA [4] => TA [5] => IA [6] => GA )
2.Array ( [0] => KA [2] => CA [4] => TA )
3.Array ( [1] => IA [3] => GA )
4.Array ( [1] => LA [3] => MA )
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); ?>
1.Array ( [0] => peach )
2.Array ( [0] => apple [1] => mango [2] => peach )
3.Array ( [0] => apple [1] => mango )
4.Array ( [0] => peach [1] => pear [2] => orange )
What will be the output of the following PHP code? <?php $fruits = array ("apple", "mango", "peach", "pear", "orange"); $subset = array_splice ($fruits, 2); print_r ($fruits); ?>
1.Error
2.Array ( [0] => apple [1] => mango [2] => peach )
3. Array ( [0] => apple [1] => mango ) d)
4.Array ( [0] => pear [1] => orange
What will be the output of the following PHP code? <?php $fruits = array ("apple", "orange", "banana"); echo (next($fruits)); echo (next($fruits)); ?>
1.orangebanana
2.appleorange
3.orangeorange
4.appleapple
What will be the output of the following PHP code? <?php $fruits = array ("mango", "apple", "pear", "peach"); $fruits = array_flip($fruits); echo ($fruits[0]); ?>
1.mango
2.error
3.peach
4.0
What will be the output of the following PHP code? <?php $number = array ("4", "hello", 2); echo (array_sum ($number)); ?>
1.4hello2
2.4
3.2
4.6
What will be the output of the following PHP code? <?php $arr = array ("lets", "find", "course", ".Com"); echo (array_search (".com", $arr) ); ?>
1. 0
2.Garbage value
3.3
4.No Output
What will be the output of the following PHP code? <?php $a = array("a" => "india", "b" => "brazil", "c" => "china"); echo array_shift($a); echo "<br>"; array_pop($a); print_r($a); ?>
1.india Array ( [b] => Brazil )
2.india Array ( [a] => brazil )
3.china Array ( [a] => india )
4.china Array ( [a] => brazil )
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); ?>
1.green
2.red
3.redArray( [c] => green [c] => blue )
4.redArray( [b] => green [c] => blue )
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", "h" => "orange"); $a3 = array("i" => "orange"); $a4 = array_merge($a2, $a3); $result = array_diff($a1, $a4); print_r($result); ?>
1.Array ( [d] => yellow )
2. Array ( [i] => orange )
3.Array ( [h] => orange )
4. Array ( [d] => yellow [h] => orange )
What will be the output of the following PHP code? <?php $a1 = array("red", "green"); $a2 = array("blue", "yellow"); print_r(array_merge($a1, $a2)); ?>
1.Array ( [0] => red [1] => green)
2. Array ( [0] => blue [1] => yellow [2] => red [3] => green )
3.Array ( [0] => red [1] => green [2] => blue [3] => yellow )
4.Array ( [0] => blue [1] => yellow )
What will be the output of the following PHP code? <?php $a1 = array_fill(1, 4, "hello"); $b1 = array_fill(5, 1, "php"); $a2 = array_merge($a1, $a2); print_r($a2); echo "<br>"; print_r($b1); ?>
1.Array ( [1] => hello [4] => hello [5] => php ) Array ( [5] => php )
2.Array ( [1] => hello [2] => hello [3] => hello [4] => hello ) Array ( [5] => php )
3.Array ( [1] => hello [2] => hello [3] => hello [4] => hello [5] => php ) Array ( [5] => php )
4.Array ( [1] => hello [2] => hello [3] => hello [4] => hello ) Array ( [1] => php )
What will be the output of the following PHP code? <?php $a1 = array_fill(3, 4, "blue"); $b1 = array_fill(0, 1, "red"); print_r($a1); echo "<br>"; print_r($b1); ?>
1.Array ( [3] => blue [4] => blue) Array ( [0] => red )
2. Array ( [4] => blue [5] => blue [6] => blue) Array ( [0] => red )
3. Array ( [3] => blue [4] => blue [5] => blue [6] => blue ) Array ()
4.Array ( [3] => blue [4] => blue [5] => blue [6] => blue ) Array ( [0] => red )
What will be the output of the following PHP code? <?php $a=array("A","Cat","Dog","A","Dog"); $b=array("A","A","Cat","A","Tiger"); $c=array_combine($a,$b); print_r(array_count_values($c)); ?>
1.Array ( [A] => 5 [Cat] => 2 [Dog] => 2 [Tiger] => 1 )
2.Array ( [A] => 2 [Cat] => 2 [Dog] => 1 [Tiger] => 1 )
3.Array ( [A] => 6 [Cat] => 1 [Dog] => 2 [Tiger] => 1 )
4.Array ( [A] => 2 [Tiger] => 1 )
What will be the output of the following PHP code? <?php $cars = array("Volvo", "BMW", "Toyota"); echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . "."; ?>
1.I like Volvo BMW and Toyota.
2.I like Volvo, BMW and Toyota)
3.I like Volvo, BMW and Toyota
4. I like. Volvo.,. BMW. and. Toyota)
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); ?>
1.Array (Peter Ben Joe)
2. Array ([Peter] => 35 [Ben] => 37 [Joe] => 43)
3.Array (35 37 43)
4.Array ([35] => Peter [37] => Ben [43] => Joe)
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; ?>
1.Sam is the brother of Bob and Bob) $brother
2.Sam is the brother of Bob and Bob)
3.$brother
4.Error
Which function returns an array consisting of associative key/value pairs?
1.count()
2.array_count()
3.array_count_values()
4.count_values()
Which function returns an array consisting of associative key/value pairs?
1.count()
2. array_count()
3.array_count_values()
4.count_values()
Which function should we use to sort the array in natural order?
1.dsort()
2.casesort()
3.natcasesort()
4.naturalsort()
Which of the following are correct ways of creating an array? i) arr[0] = "letsfindcourse"; ii) $arr[] = array("letsfindcourse"); iii) $arr[0] = "letsfindcourse"; iv) $arr = array("letsfindcourse");
1.ii), iii) and iv)
2.ii) and iii)
3.Only i) D
4.iii) and iv)
Which of the following function is used to get the value of the previous element in an array?
1.last()
2.before()
3.prev()
4.previous()
Which of the following function is used to get the value of the previous element in an array?
1. last()
2.before()
3.prev()
4.previous()
Which of the following function is Used to set the array pointer to the value of last key?
1.last()
2.end()
3.next()
4.final()
Which of the following PHP function will return true if a variable is an array or false if it is not an array?
1.this_array()
2. is_array()
3.do_array()
4. in_array()
Which of the functions is used to sort an array in descending order?
1.sort()
2.asort()
3.rsort()
4.dsort()