What will be the output of the following PHP code?
<?php
$line = "You like dogs. I hate dogs. We should marry."
$sen = preg_split('/./', $line);
print_r($sen);
?>
<?php
$line = "You like dogs. I hate dogs. We should marry."
$sen = preg_split('/./', $line);
print_r($sen);
?>
A. You like dogs. I hate dogs. We should marry.
B. Array([0]=>You like dogs. I hate dogs. We should marry.)
C. Array([0]=>You like dogs. [1]=>I hate dogs. [2]=>We should marry.)
D. Error
Answer: Option C
Solution(By Examveda Team)
We use a ‘.’ period to split the data, therefor giving each sentence it’s own array entry.Related Questions on Regular Expressions
A. 1 and 2
B. 2 and 4
C. 1 and 4
D. 2 and 3
Join The Discussion