Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




substr

substr

(PHP3 , PHP4 )

substr -- Return part of a string

Description

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

Substr returns the portion of string specified by the start and length parameters.

If start is positive, the returned string will start at the start'th character of string.

Examples:


$rest = substr ("abcdef", 1);    // returns "bcdef"
$rest = substr ("abcdef", 1, 3); // returns "bcd"
      

If start is negative, the returned string will start at the start'th character from the end of string.

Examples:


$rest = substr ("abcdef", -1);    // returns "f"
$rest = substr ("abcdef", -2);    // returns "ef"
$rest = substr ("abcdef", -3, 1); // returns "d"
      

If length is given and is positive, the string returned will end length characters from start. If this would result in a string with negative length (because the start is past the end of the string), then the returned string will contain the single character at start.

If length is given and is negative, the string returned will end length characters from the end of string. If this would result in a string with negative length, then the returned string will contain the single character at start.

Examples:


$rest = substr ("abcdef", 1, -1); // returns "bcde"
      

See also strrchr() and ereg().



With any suggestions or questions please feel free to contact us