- preg_replace: documentation ( source)
<?php
$string = ' The quick brown fox jumped over the lazy dog.';
$patterns = array();
$patterns[0] = '/^\s*/';
$replacements = array();
$replacements[0] = '';
echo preg_replace($patterns, $replacements, $string);
?>