php - 如何通过 PHP 删除空的 CSS 属性?
问题描述
我有一个这样的字符串
.header{
font-family:;
background-color:red;
color:blue;
line-height:;
}
.footer{
background-color:green;
color:;
}
我想像这样转换这个字符串
.header{
background-color:red;
color:blue;
}
.footer{
background-color:green;
}
我怎样才能做到这一点?
解决方案
尝试:
preg_replace('/.*:\s*;/i', '', $string);
虽然,输出也将包括,color:blue;
而不仅仅是?background-color:red;
.header
推荐阅读
- documentum - Documentum D2 - 未找到类类型接口 com.emc.d2fs.dctm.content.ID2Content
- java - Selenium Java - 如何通过 Selenium 从 html 中提取数字
- dialogflow-es - 如何使用 Keycloak 和 Actions on Google 进行登录?
- angular - 在管道中使用过滤器和映射来减少集合
- terraform - terraform_remote_state 数据块语法
- r - R可以区分手动加载的库和依赖项吗
- angular - 在网格的子组件中设置选定的值。角 2+
- .net-core - AutoMapper:在 Net Core 2 语法中双向映射
- javascript - 在图片下设置按钮
- angular - 可在 Ngfor 内部观察到