PHP function substr()

Availability in PHP 4.0

Return part of a string

Parameters

Parameter Data type Default value Note
$string string not String being processed.
$start int not If start is non-negative, the returned string will start at the start'th position in string, counting from zero. For example, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so on.
$length int null If length is given and is positive, the string returned will contain at most length characters starting from start (depending on the length of string).

Return values

string

|bool the extracted part of string or false on failure.

Other resources

Official substr documentation

Newsletter

Nejlepsi tipy a triky o PHP do Vaseho e-mailu. Clanky a novinky nejen ze sveta PHP a programovani.