1.  What will be the output of the following PHP code ?
$people = array(‘‘Peter’‘, ‘‘Susan’‘, ‘‘Edmund’‘, ‘‘Lucy’‘);
echo pos($people);
?>


Lucy
Peter
Susan
Edmund


Answer

 Option

The pos() function returns the value of the current element in an array, and since no operation has been done, the current element is the first element.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

2.  What will be the output of the following PHP code ?
$fruits = array (‘’website’’, ‘’print’’, ‘’exam’’);
echo (next($fruits));
echo (next($fruits));
?>


printexam
websiteprint
printprint
websitewebsite


Answer

 Option

The next() function returns the array value residing at the position immediately following that of the current array pointer.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

3.  What will be the output of the following PHP code ?
$a = array(‘‘a’‘ => ‘‘Jaguar’‘, ‘‘b’‘ => ‘‘Land Rover’‘, ‘‘c’‘ => ‘‘Audi’‘, ‘‘d’‘ => ‘‘Maseratti’‘);
echo array_search(‘‘Audi’‘, $a);
?>


a
b
c
d


Answer

 Option

The array_search() function searches for the element and returns the key of that element.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

4.  What will be the output of the following PHP code ?
$state = array (‘’Karnataka’’, ‘’Goa’’, ‘’Tamil Nadu’’,’’Andhra Pradesh’’);
echo (array_search ("Tamil Nadu", $state) );
?>


True
1
False
2


Answer

 Option

The array_search() function searches an array for a specified value, returning its key if located and FALSE otherwise.

Workspace

Answer Workspace ?>'); return false">Report

5.  What will be the output of the following PHP code ?
$city_west = array(‘‘NYC’‘, ‘‘London’‘);
$city_east = array(‘‘Mumbai’‘, ‘‘Beijing’‘);
print_r(array_replace($city_west, $city_east));
?>


Array ( [1] => Mumbai [0] => Beijing )
Array ( [0] => NYC [1] => London )
Array ( [1] => NYC [0] => London )
Array ( [0] => Mumbai [1] => Beijing )


Answer

 Option

The array_replace() function replaces the values of the first array with the values from following arrays

Workspace

Report
Mail id: Report Error:

Answer Workspace Report