<?php $str = ' Hyvor Developer '; echo strlen($str) . '<br>'; // length is 21 $str = trim($str); // remove whitespace echo strlen($str); // now, length is 15