How to use Substr () PHP Function
Programming | PHP | Wednesday, 25 January 2012 09:28
How to use Substr () PHP Function in PHP
Definition: The Substr () PHP Function is used to return part of a string. It is written as substr (string, start, optional length);.
The string is whatever string you want to return a portion of.
The start is how many characters in to skip before starting. Setting this to 3 would skip the first three and start returning at the forth character. Setting this to a negative number will start counting backwards from the end of the string.
Length is an optional parameter. If you set this to a positive number, it will return that number of characters. If you set this to a negative number it will count that many numbers from the end of the string and return whatever is left in the middle.
Examples:
| |
|
|
| |






