PHP Practice 6
PHP Practice 6
<?php
error_reporting(0);
if (strlen($membership) == 4) {
} else {
want to find within it. The function returns false if the substring is absent.*/
$membership = "pAB7";
if (strstr($membership, "MN")) {
echo "<p>Thank you. Don't forget that your membership expires soon!</p>";
} else {
/*This function tells you both whether a string exists within a larger string
//returns a portion of a string based on the start index and length of the portion you are looking
for.demands two arguments:a source string and the starting index
$test = "scallywag";
echo substr($test,6)."<br>";
echo substr($test,6,2)."<br>";
//example 2:
$test = "amazon.co.in";
} else {
//string replace
<?php
//reverse of a string
$str=strtolower($str);
echo $str."<br>";
$str=strtoupper($str);
echo $str."<br>";
//Argument swapping
<?php
$dates = array(
);
$format = include("local_format.php");
foreach($dates as $date) {
//file local_format.php
return "%02d/%02d/%d<br>";
<?php
$text = "\t\tToday is the quiz event";
echo "<pre>$text</pre>";
$text = trim($text);
echo "<pre>$text</pre>";
echo "<pre>$text</pre>";
$text = rtrim($text);
echo $text;
echo "<pre>$text</pre>";
$text = ltrim($text);
echo "<pre>$text</pre>";
arguments: the string you are transforming, the text you want to add to it, and
$membership = "mz02xyz";
echo nl2br($string);
/*wordwrap() function wraps a string into new lines when it reaches a specific length,syntax:
wordwrap(string,width,break,cut)*/
is: Supercalifragulistic";
echo wordwrap($str,15,"<br>\n");
?>