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);
?>
a) Array ( Peter Ben Joe )
b) Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
c) Array ( 35 37 43 )
d) Array ( “[Peter] => 35” “[Ben] => 37” “[Joe] => 43” )
Answer: b
Explanation: The array_combine() function creates an array by using the elements from one “keys” array and one “values” array.
Related Posts
Which of the following method scopes is/are not supported by PHP?
i) private
ii) friendly
iii) static
iv) abstractWhich of the following is/are the right way to declare a method?
i) function functionName() { function body }
ii) scope function functionName() { function body }
iii) method methodName() { method body }
iv) scope method methodName() { method body }Which one of the following is the right way to invoke a method?
Which one of the following is the right way to call a class constant, given that the class is mathFunction?
Which one of the following is the right way to define a constant?
Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
Which one of the following property scopes is not supported by PHP?
Join The Discussion