php在找到特定字符后插入换行符

php在找到特定字符后插入换行符,php,Php,我正在尝试清理一个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

我正在尝试清理一个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}}
我想在字符“{”和“}”之前和之后分别插入一个换行符

感谢您的评论。

使用函数:

str_replace(['{', '}'], ["\r\n}", "}\r\n"], $string);
使用功能:

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

$str=str\u replace(数组('{','}'),数组(“\n{\n',“\n}\n”),$str)
还有一些工具/web应用程序可以用来清理文件,这基本上就是一行
.css
文件(一般来说)。他没有要求缩进!;)这就做到了,哈哈,非常感谢你,我对这一切都是新手,我正在学习一些php,但谁知道有一种方法可以让这些垃圾清晰可辨。谢谢你,伙计,你解决了它<代码>$str=str\u replace(数组('{','}'),数组(“\n{\n',”\n}\n”),$str)还有一些工具/web应用程序可以用来清理文件,这基本上就是一行
.css
文件(一般来说)。他没有要求缩进!;)这就做到了,哈哈,非常感谢你,我对这一切都是新手,我正在学习一些php,但谁知道有一种方法可以让这些垃圾清晰可辨。谢谢你,伙计,你解决了它!