html是这样的
<div class="itemCartContaine"><input type="radio" name="BTN_GROUP_59679208328481" value="22334875:SHIP_TO_HOME:1" onclick=""><input type="radio" name="BTN_GROUP_59679208328481" value="22334875:SHIP_TO_HOME:2" onclick=""><input type="radio" name="BTN_GROUP_59679208328481" value="22334875:SHIP_TO_HOME:3" onclick="" checked=""><textarea id="IncludeMessage" name="TEXTAREA_59679208328481" onclick="WALMART.checkout.shipping.giftMsgOnClick(this);" onkeyup="WALMART.checkout.shipping.giftMsgLimiter(this, 59679208328481)">Enter your gift message here</textarea></div><div class="itemCartContaine"><input type="radio" name="BTN_GROUP_59679208328482" value="22334876:SHIP_TO_HOME:1" onclick=""><input type="radio" name="BTN_GROUP_59679208328482" value="22334876:SHIP_TO_HOME:2" onclick="" checked=""><input type="radio" name="BTN_GROUP_59679208328482" value="22334876:SHIP_TO_HOME:3" onclick=""><textarea id="IncludeMessage2" name="TEXTAREA_59679208328482" onclick="" onkeyup="">Enter your gift message here2</textarea></div>
[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='/<input type="radio" name="([^"]*?)" value="([^"]*?)" ([^>]*?)>(.*?)<input type="radio" name="([^"]*?)" value="([^"]*?)" ([^>]*?)>(.*?)<input type="radio" name="([^"]*?)" value="([^"]*?)" ([^>]*?)>(.*?)<textarea id="([^"]*?)" name="([^"]*?)" ([^>]*?)>([^<]*?)<\/textarea>/sm';
上面得出的结果是:
[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=<<.+?登入後複製