Showing posts with label How can I replace whitespace with underscores in php?. Show all posts
Showing posts with label How can I replace whitespace with underscores in php?. Show all posts

Sunday 3 April 2016

How can I replace whitespace with underscores in php?

The \s character class will match whitespace characters. I've added the + quantifier to collapse multiple whitespace to one _. If you don't want that, remove the +

$picture =preg_replace('/\s+/', '_', uniqid()."_".$image_name);