Issue
I can convert Space to dash.
$string = str_replace(' ', '-', $string);
But I want to convert a number of spaces; two, three, four, five, six or soon.. spaces into single dash
into -
Solution
Try this regex using preg_replace
$string = preg_replace( '!\s+!', '-', $string );
Answered By - Amit Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.