"/>
Home / CSE / PHP - CS :: Discussion

Discussion :: PHP - CS

  1. 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);

    ?>

  2. A.

     Array ( [0] => pasta [1] => steak [2] => fish [3] => potatoes )

    B.

     Array ( [3] => potatoes )

    C.

     Array ( [1] => steak )

    D.

     Array ( [0] => potatoes )

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    This function is used to search an array for foods beginning with s.


Be The First To Comment