21. 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);
?>
22. What will be the output if we replace the line $num = preg_grep(“/[0-5]/”, $number); with $num = preg_grep(“/[0-5]/”, $number, PREG_GREP_INVERT);?
23. Which one of the following functions is used to search a string?
24. What will be the output of the following PHP code?
<?php
$name = "What is your name?"
if (preg_match("/name/"),$name)
echo "My name is Will Pitt ";
else
echo "My name is not Will Pitt ";
if (preg_match("/are/"))
echo "I am great"
else
echo "I am not great";
?>
<?php
$name = "What is your name?"
if (preg_match("/name/"),$name)
echo "My name is Will Pitt ";
else
echo "My name is not Will Pitt ";
if (preg_match("/are/"))
echo "I am great"
else
echo "I am not great";
?>
25. Which one of the following preg PHP function is used to do a find and replace on a string or an array?
26. What will be the output of the following PHP code?
<?php
$str = "Hello! My name is Cameron Fox. Coffee?"
$find = array('/is/','/coffee/');
$replace = array('/was/','/tea/');
echo preg_replace ($find, $replace, $str);
?>
<?php
$str = "Hello! My name is Cameron Fox. Coffee?"
$find = array('/is/','/coffee/');
$replace = array('/was/','/tea/');
echo preg_replace ($find, $replace, $str);
?>
27. Which one of the following preg PHP functions is used to take a string, and put it in an array?
28. 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);
?>