<?php
$str = "Hello! My name is Cameron Fox. Coffee?"
$find = array('/is/','/coffee/');
$replace = array('/was/','/tea/');
echo preg_replace ($find, $replace, $str);
?><?php
$line = "You like dogs. I hate dogs. We should marry."
$sen = preg_split('/./', $line);
print_r($sen);
?><?php
$number = array(0,1,two,three,four,5);
$num = preg_grep("/[0-5]/", $number);
print_r($num);
?><?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
echo str_pad("Salad", 5)." is good.";
?><?php
$author = "[email protected]";
$author = str_replace("a","@",$author);
echo "Contact the author of this article at $author.";
?><?php
$url = "[email protected]";
echo ltrim(strstr($url, "@"),"@");
?><?php
$foods = array("pasta", "steak", "fish", "potatoes");
$food = preg_grep("/^s/", $foods);
print_r($food);
?><?php
$title = "O'malley wins the heavyweight championship!";
echo ucwords($title);
?>