Discussion :: PHP - CS
-
What will be the output of the following PHP code?
<?php
$number = array(0,1,two,three,four,5);
$num = preg_grep("/[0-5]/", $number);
print_r($num);
?>
A.
Array([0]=>0 [1]=>1 [2]=>two [3]=>three [4]=>four [5]=>5) |
B.
Array([2]=>two [3]=>three [4]=>four) |
C.
Array([1]=> 1) |
D.
Array([0]=>0 [1]=>1 [5]=>5) |
Answer : Option D
Explanation :
The preg_grep function is used to search an array for specific patterns and then return a new array based on that filtering.
Be The First To Comment