php - Consecutive find/replace with regexp -


this question has answer here:

say want erase quote string, , replace spaces '&', in php. 2 consecutive preg_replace or like, how in 1 passage?

" columns="4" link="file" ids="280,281,282,283,284,285,286,287,288"" 

to:

columns=4&link=file&ids=280,281,282,283,284,285,286,287,288 

you don't need regex that. str_replace() should work fine:

$string = 'columns="4" link="file" ids="280,281,282,283,284,285,286,287,288"'; $replaced = str_replace([' ', '"'], ['&', ''], $string); 

demo: https://3v4l.org/ghhmp


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -