how to change spaces more than one into underscore, but not change single spaces?
First:
21 Facebook Inc 6 860,000
Result:
21_Facebook Inc_6_860,000
how to change spaces more than one into underscore, but not change single spaces?
First:
21 Facebook Inc 6 860,000
Result:
21_Facebook Inc_6_860,000
you should used preg_replace
function. for more details read PHP preg_replace
manual
Here is the example
$string="21 Facebook Inc 6 860,000";
$string = preg_replace('/[\t
\0\x0B]/', '', $string);
$string = preg_replace('/([\s])\1+/', '_', $string);
print_r($string);
You can check your desired output