日期:2014-05-17 浏览次数:20629 次
html内容:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK" /> <title>无标题文档</title> <script language="javascript"> function initSelect(){ var option1 = new Option("福建", "福建"); var option2 = new Option("陕西", "陕西"); document.getElementById("province").options.length = 1; document.getElementById("province").options.add(option1); document.getElementById("province").options.add(option2); } function changeProvince(){ var pro = document.getElementById("province").value; switch(pro){ case "福建": var option0 = new Option("--请选择--", ""); var option1 = new Option("福州", "福州"); var option2 = new Option("厦门", "厦门"); var option3 = new Option("泉州", "泉州"); break; case "陕西": var option0 = new Option("--请选择--", ""); var option1 = new Option("西安", "西安"); var option2 = new Option("宝鸡", "宝鸡"); var option3 = new Option("咸阳", "咸阳"); break; } document.getElementById("city").options.length = 0; document.getElementById("city").options.add(option0); document.getElementById("city").options.add(option1); document.getElementById("city").options.add(option2); document.getElementById("city").options.add(option3); } </script> </head> <body onLoad="initSelect()"> <table width="200" border="0" cellspacing="0" cellpadding="10" > <tr> <td> <select name="province" id="province" onChange="changeProvince()"> <option value=""> --请选择-- </option> </select>省 </td> <td> <select name="city" > <option value=""> --请选择-- </option> </select>市 </td> </tr> </table> </body> </html>?
正则匹配HTML内容
//header('Content-Type:text/html;chaset=utf-8;'); $str = file_get_contents("http://www.myip.cn/ename.cn"); //$str = "<td class='td_bold'>IP所在地:</td><td id='res_iplocation_0'>广东省中山市 电信<br><img width=18 border=0"; preg_match("/IP所在地:<\/td><td id=\'res_iplocation_0\'>([".chr(0xa1)."-".chr(0xff)."\s]+)<br>/si", $str, $matches); //preg_match("/res_iplocation_0[\'\"\s]*>(.*?)<br>/si", $str, $matches); print_r($matches);?