有没有一种方法可以preg_replace
用来替换A
for B
if A
is present 或B
for A
if B
is present?
就像是:
preg_replace('/ORDER BY field (ASC|DESC)/', 'ORDER BY field (***the alternative not matched***)');
将 anyORDER BY field ASC
转换为ORDER BY field DESC
,并将 anyORDER BY field DESC
转换为ORDER BY field ASC
。