Strings In Depth9 / 18
Up next

Trim whitespace

<?php
declare(strict_types=1);
$s = "  padded  ";
// trim removes whitespace from both ends
var_dump(trim($s));
// a second argument sets which characters to strip
echo trim("--x--", "-"), "\n";
What you're solving

trim, and trimming custom characters