What are the differences between trim() and ltrim() functions in PHP?

The trim() function in PHP removes whitespace (or other specified characters) from both the beginning and end of a string, while the ltrim() function only removes whitespace (or other specified characters) from the beginning of a string. If you only need to remove leading whitespace, use ltrim(). If you need to remove both leading and trailing whitespace, use trim().

// Example of using trim() and ltrim() functions
$string = "  Hello World  ";
$trimmed_string = trim($string); // $trimmed_string = "Hello World"
$left_trimmed_string = ltrim($string); // $left_trimmed_string = "Hello World  "