ltrim() and rtrim() function examples

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);

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);

!Hello World42!

echo rtrim($string, " \t!0..9");
// Range included is all numbers between 0 and 9, tab, space, and exclamation point.

!Hello World

Similar Posts: