Hector Valadez Gil
Hector Valadez Gil

Reputation: 13

php Insert line break after certain character is found

I'm trying to clean a CSS script, which consists of a single line, like this:

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}}

and i would like to insert a line break before and after the characters "{" and "}" respectively.

I appreciate your comments.

Upvotes: 1

Views: 2425

Answers (1)

pavel
pavel

Reputation: 27082

Use str_replace() function:

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

Upvotes: 4

Related Questions