The examples presented for both ltrim() and rtrim() are accurate in their results, however the stated functions used is actually trim(). Thus, here are the corrected examples:
$string = " \n Hello World!";
echo ltrim($string, " \nA..Ha..z!");
// All capital letters between A and H, all lowercase letters, exclamation point, space, and newline
$string = "!Hello World42! \t\t";
echo rtrim($string, " \t!0..9");
// Range included is all numbers between 0 and 9, tab, space, and exclamation point.
A really minor correction. In the first sentence describing the function, it states:
Returns an array with they keys…
It should read:
Returns an array with the keys…
In the last sentence, it includes some extraneous words: ”number of matches”. It should simply read:
Returns: 1 if matched, 0 if no match, and FALSE on error.
On page 131, the fwrite() function has a TIP that reads:
To read the entire file into a string, use the function filesize().
// file.txt contains the sentence: Hello World!
$filename = 'file.txt';
$file = fopen($filename, 'r');
$string = fread( $file, filesize($filename) );
// file.txt now contains at the end: Hello World!
You’ll notice that this is the same tip as fread() and doesn’t belong. It should be considered ‘removed’.
Some quick corrections for the Function Index: