/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $string = 'This string has no whitespaces.'; ?> Output: This string has no white spaces. // OR EVEN BETTER trim's code can of course be simplified with some use of the trim() function.... <?php $str = " Words with lots of spaces "; ?> Doing the trim() first reduces the workload being put on the more expensive preg_replace().