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);
?>
<?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
Solution(By Examveda Team)
This function is used to search an array for foods beginning with s.Related Questions on Regular Expressions
A. 1 and 2
B. 2 and 4
C. 1 and 4
D. 2 and 3
Join The Discussion