substr
(PHP 4, PHP 5, PHP 7)
substr — Return part of a string
Description ¶
string substr ( string
$string , int $start [, int $length ] )
Returns the portion of
string specified by the start and length parameters.Parameters ¶
string- The input string. Must be one character or longer.
start- If
startis non-negative, the returned string will start at thestart'th position instring, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.Ifstartis negative, the returned string will start at thestart'th character from the end ofstring.Ifstringis less thanstartcharacters long,FALSEwill be returned.Example #1 Using a negativestart<?phpecho substr ("abcde" , 0,3 ); ?>retrun abc
No hay comentarios:
Publicar un comentario