PHP substr() function

php substr function

<?php   // PHP program to illustrate substr() function Substring($str){     $len = strlen($str);     echo substr($str, 8), “\n”;     echo substr($str, 5, $len), “\n”;     echo substr($str, -5, 10), “\n”;     echo substr($str,-8, -5), “\n”; }   // Driver Code $str=”blogsforblogs”; Substring($str);   ?> Output: blogs forblogs blogs for The substr() is a built-in function in PHP that is … Read more

get the last 7 characters of a PHP string

php-mysql

get the last 7 characters of a PHP string Use substr() with a negative number for the 2nd argument. $newstring = substr($dynamicstring, -7); string substr ( string $string , int $start [, int $length ] ) If start is negative, the returned string will start at the start’th character from the end of string Example: <?php echo … Read more