php在找到某个字符后插入换行符


php Insert line break after certain character is found

我正在尝试清理一个CSS脚本,它由一行组成,如下所示:

footer .column .f-links li a{color:#1297de;font-size:14px}footer .column .address{font-size:14px;color:#3d3d3d}footer .column .infos{margin-top:10px;color:#3d3d3d}footer .column .infos .phone{background:url("../images/icon-phone.png") no-repeat 0 2px;padding:0 0 0 25px;margin-bottom:10px}@media (min-width:1023px) and (max-width:1024px){footer .column .infos .phone{font-size:10px;line-height:24px;padding-top:7px}footer .column .infos .email{font-size:10px;padding-top:7px}}

我想在字符"{"answers"}"之前和之后分别插入一个换行符。

我感谢你的评论。

使用str_replace()函数:

str_replace(['{', '}'], ["'r'n}", "}'r'n"], $string);