关于正则表达式的问题,非常感谢!
以下为抓取到的页面,想通过正则表达式函数取出里边的关于教师课表安排的信息,希望各位大侠给帮忙,谢谢。
HTTP/1.1 200 OK
Connection: close
Date: Thu, 07 May 2015 07:44:28 GMT
Server: YxlinkWAF
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/html; charset=gb2312
Content-Length: 11062
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<br />include 'simple_html_dom.php';//这个你可以在网上下载一个<br /><br />$dom=new simple_html_dom();<br />//要将内容转为 utf-8 才能处理<br />$dom->load($content);<br />$names=$dom->find('select[id=js]');<br />$res=array();<br />$res['name']=$names[0]->find('option[selected=selected]')[0]->text();<br />$tabletr=$dom->find('table[id=Table6] tr');<br />foreach($tabletr as $k=>$tr){<br /> foreach($tr->find('td') as $k1=>$td){<br /> if($k1!==0){<br /> $info[$k][$k1]=$td->text();<br /> }<br /> }<br />}<br />//优化数据<br />foreach($info as $k=>$v){<br /> if($k==1){<br /> unset($info[1]);<br /> }<br /> if(count($v)==8){<br /> unset($v[1]);<br /> }<br /> $info[$k]=array_values($v);<br />}<br />$week=$info[0];<br />unset($info[0]);<br />//组织数据<br />foreach($info as $v){<br /> foreach($v as $k=>$v){<br /> $tmp[$week[$k]][]=$v;<br /> }<br />}<br />$res['info']=$tmp;<br /><br />echo "<pre class="brush:php;toolbar:false">";<br />print_r($res);<br />echo "
";<br />print_r($arr);<br />echo "