MENU
Substring
substr($s1,$i1[,$i2]) returns a substring of $s1 that is $i2 long, starting from position $i1. If $i1 is negative, the returned string will start at the $i-th character from the end. If $i2 is negative, that many characters will be omitted from the end. strstr($s1,$s2[,$b=false]) or strchr(……) returns a substring of $s1, starting from the first occurrence of $s2 to the end. If $b is true, the function returns the part of $s1 before the first occurrence of $s2. FALSE is returned if $s2 cannot be found. stristr(……) is similar to strstr(……) but is case-insensitive. strrchr($s1,$s2) returns a substring of $s1, starting at the last occurrence of $s2 until the end. If $s2 contains more than one character, only the first is used. strpbrk($s1,$s2) returns a substring of $s1, starting from the first occurrence of any character from $s2, to the end.RESETRUNFULL
<!DOCTYPE html><html><head></head>
<body><?php
echo substr("abcdefgh",3)."<br />"; // defgh
echo substr("abcdefgh",-3,2)."<br />"; // fg
echo substr("abcdefgh",3,-2)."<br />"; //def
echo strstr("abcdefgh","cde")."<br />"; //cdefgh
echo stristr("abcdefgh","cDE",true)."<br />"; //ab
echo strrchr("abcabcdef","aXX")."<br />"; //abcdef
echo strpbrk("abcdefgh","xyze")."<br />"; //efgh
?></body></html>