Q. What is the result of the following PHP code?

Code:
<?php
    $names = array("alex", "jean", "emily", "jane");
    $name = preg_grep("/^e/", $names);
    print_r($name);
?>
  • (A) Array ( [0] => alex [1] => jean [2] => emily [3] => jane )
  • (B) Array ( [0] => alex )
  • (C) Array ( [2] => emily )
  • (D) Array ( [3] => jane )
πŸ’¬ Discuss
βœ… Correct Answer: (C) Array ( [2] => emily )
Explanation: The built-in function preg_grep() returns an array containing only items from the input that match the given pattern.
Explanation by: Akshay Kulkarni
The built-in function preg_grep() returns an array containing only items from the input that match the given pattern.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
196
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Akshay Kulkarni
Publisher
πŸ“ˆ
95%
Success Rate