<?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";
trim, and trimming custom characters