Table of contents Home page
echo substr('alpha', 3), "\n"; // Return the part of the bytes starting at position 3 (first one is 0!) echo substr('alpha', -3), "\n"; // Return the last 3 bytes. // Note that substr may have been re-defined as an alias of mb_substr by setting the value of mbstring.func_overload in // php.ini, in which case it will work with CHARACTERS instead of BYTES. // If that is the case and you want to extract bytes, use mb_substr instead with 'ascii' as its fourth argument.
echo substr('alpha', 3, 1), "\n"; // Return the byte at position 3 (first one is 0!) echo substr('alpha', -3, 1), "\n"; // Return the third byte from the right (rightmost one is 1!) // Note that substr() may have been re-defined as an alias of mb_substr() by setting the value of mbstring.func_overload // in php.ini, in which case it will work with CHARACTERS instead of BYTES. // If that is the case and you want to extract bytes, use mb_substr() instead with 'ascii' as its fourth argument.