A

Admin • 828.03K Points
Coach

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 )
  • Correct Answer - Option(C)
  • Views: 9
  • Filed under category PHP
  • Hashtags:

Explanation by: Admin
The built-in function preg_grep() returns an array containing only items from the input that match the given pattern.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.