Tuesday, 30 June 2015

How To make sub-string in PHP ?

string substr ( string $string , int $start [, int $length ] )

Returns the portion of string specified by the start and length parameters.

<?php
echo substr('abcdef', 1);     // bcdef
echo substr('abcdef', 1, 3);  // bcd
echo substr('abcdef', 0, 4);  // abcd
echo substr('abcdef', 0, 8);  // abcdef
echo substr('abcdef', -1, 1); // f

?>

No comments:

Post a Comment