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);
?>
<?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
Solution(By Examveda Team)
The preg_grep function is used to search an array for specific patterns and then return a new array based on that filtering.Related Questions on Regular Expressions
A. 1 and 2
B. 2 and 4
C. 1 and 4
D. 2 and 3
Join The Discussion