<?
/*
The following note is only about the first few statements in this 
program:
Here is how to remove a leading substring from a string. 
For example, I want here to remove /home/abu-jeib/www/
from the path of the file. The new string will be the second 
elemnt of the returned array (the first element of that 
array will be the empty string). Note that it is not necessary here 
to supply a third argument (which is the number of elements in the array 
I want which is in this case 2). You can use explode or split.
*/
echo 'When $s="/home/abu-jeib/www/teaching/Fall_06/207/a.php":<BR>';
echo 'The elements of $ar when $ar = split("/home/abu-jeib/www/",$s,2) are:<BR>';

$s="/home/abu-jeib/www/teaching/Fall_06/207/a.php";
$ar = split("/home/abu-jeib/www/",$s,2);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "=======================<p>\n";

echo 'The elements of $ar when $ar = explode("/home/abu-jeib/www/",$s,2) are:<br>';
$ar = explode("/home/abu-jeib/www/",$s,2);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "=======================<p>\n";
echo 'When $s = "This iS a sgood   thing":<br>';
echo 'The elements of $ar when $ar = explode(" ",$s):<br>';
$s = "This iS a sgood 	thing";
$ar = explode(" ",$s);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "===============<p>\n";
echo 'The elements of $ar when $ar = explode("s",$s):<br>';
$ar = explode("s",$s);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "===============<br>";
echo 'When $s = "ab,cde,fg": <br>';
echo "The elements of \$ar when \$ar = explode(',',\$s) are: <br>";
$s = "ab,cde,fg";
$ar = explode(',',$s);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "===============<br>";
echo 'When $ar is as above: <br>';
echo '$a in $a = implode($ar) is: <br>';
$a = implode($ar);
echo "\$a = \"$a\"<br>";
echo "===============<br>";
echo 'When $ar is as above: <br>';
echo '$a in $a = implode($ar,",") is: <br>';

$a = implode($ar,",");
echo "\$a = \"$a\"<br>";
echo "===============<br>";

echo 'When $s = "ab,cde,fg", the elements of $ar when $ar = explode(",",$s,2) are: <br>';

$s = "ab,cde,fg";
$ar = explode(',',$s,2);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "===============<br>";

echo 'When $s = "ab,cde;fg,hi,jk;lm=n", the elements of $ar when $ar = split(",|;|=",$s), are:<br>';
$s = "ab,cde;fg,hi,jk;lm=n";
$ar = split(",|;|=",$s);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "===========HERE ====<br>";
echo 'When $s = "abu-jeib@cs.fredonia.edu", the elements of $ar when $ar = split("\@|\.",$s), are:<br>';
$s = "abu-jeib@cs.fredonia.edu";
$ar = split("\@|\.",$s);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";
echo "================<br>";
echo 'When $s = "abu-jeib@cs.fredonia.edu", the elements of $ar when $ar = explode("\@|\.",$s), are:<br>';
$ar = explode("\@|\.",$s);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "===============<br>";

//---------------
echo "===========HERE ====<br>";
echo 'When $s = "abu-jeib@cs.fredonia.edu", the elements of $ar when $ar = split("@|.",$s), are:<br>';
$s = "abu-jeib@cs.fredonia.edu";
$ar = split("@|.",$s);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";
echo "================<br>";
echo 'When $s = "abu-jeib@cs.fredonia.edu", the elements of $ar when $ar = explode("@|.",$s), are:<br>';
$ar = explode("@|.",$s);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "===============<br>";

//--------------
echo 'When $s = "abu-jeib@cs.fredonia.edu", the elements of $ar when $ar = split("\@|\.",$s,2), are:<br>';
$s = "abu-jeib@cs.fredonia.edu";
$ar = split("\@|\.",$s,2);
foreach ($ar as $k => $v)
        echo "\$ar[$k] = \"$v\"<br>";

echo "===============<br>";
echo 'When $s="zAbcabdababyAb", the value of: <br>';
$s="zAbcabdababyAb";
echo 'strpos($s,"ab"):<br>';
echo strpos($s,"ab"), "<br>";
echo 'strpos($s,"ab",5): <br>';
echo strpos($s,"ab",5), "<br>";
echo 'stripos($s,"ab"): <br>';
echo stripos($s,"ab"), "<br>";
echo 'strrpos($s,"ab"): <br>';
echo strrpos($s,"ab"), "<br>";
echo 'strripos($s,"ab"): <br>';
echo strripos($s,"ab"), "<br>";

?>
