Nice quick one for you guys, hope you can help.
After a dodgy CMS I created a while ago, my database is full of product 'names' that have either 1, 2 or 3 spaces before the actual name. This is causing me havoc now and I'm wondering if there's a function that will let me remove these pesky spaces in PHP instead of having to update the database (hundreds of entries).
To make it clearer here's what I'm trying to achieve.
//swap spaces in name for hyphens
$SEOname = str_replace(' ','-',$name);
//works fine on all entries that don't have preceding spaces, but occasionally leads to this
---concrete-fence-posts
Hope you can help.
Thanks.