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
Post a Comment