CSE :: PHP - CS
- 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);?
- Which one of the following functions is used to search a string?
-
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";
?>
- Which one of the following preg PHP function is used to do a find and replace on a string or an array?
-
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);
?>
- Which one of the following preg PHP functions is used to take a string, and put it in an array?
-
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);
?>
- Which one of the following is not a preg PHP function?