0
我试图解析如下代码:解析HTML元素插入部分
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable" style="table-layout: fixed;max-width:100% !important;width: 100% !important;min-width: 100% !important;">
基本上我需要的是:
Array
(
[0] => <table
[1] => border="0"
[2] => cellpadding="0"
[3] => cellspacing="0"
[4] => height="100%"
[5] => width="100%"
[6] => id="bodyTable"
[7] => style="table-layout: fixed;max-width:100% !important;width: 100% !important;min-width: 100% !important;
)
但是用一个简单的explode(" ", $str);
这样做时,我得到“风格”也分解了,有没有一种简单的方法来解析并循环通过它?
如果你正在使用的空间在'爆炸)分隔符('从'style'属性中删除空格。 – coderodour
如果你只是在寻找一个快速的hacky解决方案,你也可以尝试正则表达式。 – dan08
http://php.net/manual/en/function.explode.php – Aaron