View Single Post
Old 07-20-2009, 11:13 AM   #3 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

You could also use a single call to preg_replace with multiple patterns/replacements.

PHP Code:
$subject 'This is bullshit M$ Word. They make   me 100% crazy.';
$search  = array('/[^a-z0-9 ]+/i''/ +/');
$replace = array('''-');
echo 
preg_replace($search$replace$subject);
// Output: This-is-bullshit-M-Word-They-make-me-100-crazy 
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
superthin (07-20-2009)