What Will Be The Output Of The Following Php Codep Pre Langphp #152
What will be the output of the following PHP code?</p> <pre><code class="language-php" line="1"> <?php $foods = array("pasta", "steak", "fish", "potatoes"); $food = preg_grep("/^s/", $foods); print_r($food); ?> </code></pre>
This multiple choice question (MCQ) is related to the book/course
gs gs107 PHP: Hypertext Preprocessor.
It can also be found in
gs gs107 Strings and Regular Expressions - PHP Strings & Regular Expressions - Quiz No.2.
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); ?>
Array ( [0] => pasta [1] => steak [2] => fish [3] => potatoes )
Array ( [3] => potatoes )
Array ( [1] => steak )
Array ( [0] => potatoes )