用正则表达式连续查找/替换[复制]

This question already has an answer here:

Say I want to erase any quote from this string, and then replace spaces with '&', in php. I could easily do with 2 consecutive preg_replace or the like, but how to do it in only 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
</div>

You don't need regex for 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