Example 1 — Remove Leading Spaces
The everyday use: clean up extra spaces before text.
<?php
$text = " Hello, CodeToFun";
$clean = ltrim($text);
echo "[" . $clean . "]", PHP_EOL; How It Works
- Start with spaces. Three spaces come before the text.
- Call ltrim with one argument. It uses the default whitespace list.
- Spaces are removed. Stripping stops at the first H.
- Brackets show the edges. There is no space after the opening bracket.

