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
start
is 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.Ifstart
is negative, the returned string will start at thestart
'th character from the end ofstring
.Ifstring
is less thanstart
characters long,FALSE
will be returned.Example #1 Using a negativestart
<?php
echo substr ("abcde" , 0,3 );
?>
retrun abc
No hay comentarios:
Publicar un comentario