Q.1
Parameter flags was added in which version of PHP?
Q.2
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);
?>
Q.3
Which one of the following preg PHP functions is used to take a string, and put it in an array?
Q.4
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);
?>
Q.5
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);
?>
Q.6
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);?
Q.7
Which one of the following is not a preg PHP function?
Q.8
Which one of the following functions is used to search a string?
Q.9
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";    
?>
Q.10
Which one of the following preg PHP function is used to do a find and replace on a string or an array?
Q.11
What will be the output of the following PHP code?
<?php
echo str_pad("Salad", 5)." is good.";
?>
Q.12
Which one of the following functions can be used to concatenate array elements to form a single delimited string?
Q.13
Which one of the following functions finds the last occurrence of a string, returning its numerical position?
Q.14
How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.
Q.15
What will be the output of the following PHP code?
<?php
$author = "[email protected]";
$author = str_replace("a","@",$author);
echo "Contact the author of this article at $author.";
?>
Q.16
What will be the output of the following PHP code?
<?php
$url = "[email protected]";
echo ltrim(strstr($url, "@"),"@");
?>
Q.17
What will be the output of the following PHP code?
<?php
$foods = array("pasta", "steak", "fish", "potatoes");
$food = preg_grep("/^s/", $foods);
print_r($food);
?>
Q.18
Say we have two compare two strings which of the following function/functions can you use?
1. strcmp()
2. strcasecmp()
3. strspn()
4. strcspn()
Q.19
Which one of the following functions will convert a string to all uppercase?
Q.20
What will be the output of the following PHP code?
<?php
$title = "O'malley wins the heavyweight championship!";
echo ucwords($title);
?>
0 h : 0 m : 1 s