Discussion :: PHP - CS
-
What will be the output of the following PHP code?
<?php
$foods = array("pasta", "steak", "fish", "potatoes");
$food = preg_grep("/^s/", $foods);
print_r($food);
?>
A.
Array ( [0] => pasta [1] => steak [2] => fish [3] => potatoes ) |
B.
Array ( [3] => potatoes ) |
C.
Array ( [1] => steak ) |
D.
Array ( [0] => potatoes ) |
Answer : Option C
Explanation :
This function is used to search an array for foods beginning with s.
Be The First To Comment