时间:2021-07-01 10:21:17 帮助过:6人阅读
[1] => Array ( [0] => BTN_GROUP_59679208328481 [1] => BTN_GROUP_59679208328482 [2] => TEXTAREA_59679208328481 [3] => TEXTAREA_59679208328482 ) [2] => Array ( [0] => 22334875:SHIP_TO_HOME:3 [1] => 22334876:SHIP_TO_HOME:2 [2] => Enter your gift message here [3] => Enter your gift message here2 )
在线等...
$pattern='/]*?)>(.*?)]*?)>(.*?)]*?)>(.*?)
上面得出的结果是:
[1] => Array ( [0] => BTN_GROUP_59679208328481 [1] => BTN_GROUP_59679208328482 ) [2] => Array ( [0] => 22334875:SHIP_TO_HOME:1 [1] => 22334876:SHIP_TO_HOME:1 ) [3] => Array ( [0] => onclick="" [1] => onclick="" ) [4] => Array ( [0] => [1] => ) [5] => Array ( [0] => BTN_GROUP_59679208328481 [1] => BTN_GROUP_59679208328482 ) [6] => Array ( [0] => 22334875:SHIP_TO_HOME:2 [1] => 22334876:SHIP_TO_HOME:2 ) [7] => Array ( [0] => onclick="" [1] => onclick="" checked="" ) [8] => Array ( [0] => [1] => ) [9] => Array ( [0] => BTN_GROUP_59679208328481 [1] => BTN_GROUP_59679208328482 ) [10] => Array ( [0] => 22334875:SHIP_TO_HOME:3 [1] => 22334876:SHIP_TO_HOME:3 ) [11] => Array ( [0] => onclick="" checked="" [1] => onclick="" ) [12] => Array ( [0] => [1] => ) [13] => Array ( [0] => IncludeMessage [1] => IncludeMessage2 ) [14] => Array ( [0] => TEXTAREA_59679208328481 [1] => TEXTAREA_59679208328482 ) [15] => Array ( [0] => onclick="WALMART.checkout.shipping.giftMsgOnClick(this);" onkeyup="WALMART.checkout.shipping.giftMsgLimiter(this, 59679208328481)" [1] => onclick="" onkeyup="" ) [16] => Array ( [0] => Enter your gift message here [1] => Enter your gift message here2 )
应该是2,6,10,16才是匹配需要的内容
提供正则,然后你自己再处理下就可以实现。
$s=<<div;preg_match_all('/name="([^\"]+)" value="([^\"]+)" onclick="" checked="">.+?