Can someone please let me know how I would remove multiple commas if they were next to one another in PHP.
$address= rtrim(preg_replace('!s+!', ' ', $address_line_1.' '.$address_line_2.', '.$town_village_city.', '.$state_province_county.', '.$postal_code.', '.$country),',');
//return preg_replace('/([!?,.])+/',' ',$address);
return preg_replace('!,+!',' ',$address);
For example I may have an address with no town_village so end up with multiple commas.
Also anyone good resources for testing PHP regex?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…