remove space from beginning of string php code example Example: remove empty spaces php $string = str_replace(' ', '', $string);