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