PHP:Substring

From Progzoo
Jump to: navigation, search

Use substr(a,b) to get part of a string.

substr(5,2) extracts 2 characters from position.

0 1 2 3 4 5 6 7 8 9 10 11 12
O n e t w o t h r e e
f o u r f i v e s i x


[Font] [Default] [Show] [Resize] [History] [Profile]

Use substr(a) to get part of a string.

substr(5) extracts characters form position 5 to the end.

0 1 2 3 4 5 6 7 8 9 10 11 12
O n e t w o t h r e e
f o u r f i v e s i x


[Font] [Default] [Show] [Resize] [History] [Profile]

Use [a] to get a single character from a string.

[5] extracts the character form position 5.

0 1 2 3 4 5 6 7 8 9 10 11 12
O n e t w o t h r e e
f o u r f i v e s i x


[Font] [Default] [Show] [Resize] [History] [Profile]