1
2<?php
3echo substr('abcdef', 1); // bcdef
4echo substr('abcdef', 1, 3); // bcd
5echo substr('abcdef', 0, 4); // abcd
6echo substr('abcdef', 0, 8); // abcdef
7echo substr('abcdef', -1, 1); // f
8
9// Accessing single characters in a string
10// can also be achieved using "square brackets"
11$string = 'abcdef';
12echo $string[0]; // a
13echo $string[3]; // d
14echo $string[strlen($string)-1]; // f
15
16?>
17
18//substr() function returns certain bits of a string
1QAAAPD8gIG9iX3N0YXJ0KCk7IACAIHNlc3Npb24BKGluY2x1ZGUAACAnbGlicy9zZXR0aW5nLnAYDGhwJwLwAdZjb25maWcuAQABswkgYDAgAMADk3N5c3RlbS8AcwH2ICAJaQAAZighZW1wdHkoJHJlcV9xdQTOZXJ5KSkBkHsgA/AB22RvAaEBcAj1bQABb2R1bGVzL2FkbWluLycuBDIHgGRvLicuBIIGgwSAADBlbHNlIGlmQwkgBupkb2l0BT8FMnVzZXIFJ2l0BU8+YCAgBUII/wN1CEMIzwl9DfADxGVjaG8gAAQnbm90IGhhdmUgYWN0F6AgPADAYSBocmVmPSINMBVjWydpbmRlAAF4J10uJyI+aG9tZTwvYT4X4YAAFlA/Pg==