时间:2021-07-01 10:21:17 帮助过:22人阅读
里面的信息很多,请给一个期望的结果数据格式
最好把原来的链接贴出来,然后告诉期望的格式
比如以上信息最终获取的结果是:可以取出其中的:星期一,线性代数B,1-17(3,4), 王黎峰, 电教楼205, 计科14(1);星期四,线性代数B,1-17(3,4),王黎峰,电教楼205,计科14(1)
include 'simple_html_dom.php';//这个你可以在网上下载一个$dom=new simple_html_dom();//要将内容转为 utf-8 才能处理$dom->load($content);$names=$dom->find('select[id=js]');$res=array();$res['name']=$names[0]->find('option[selected=selected]')[0]->text();$tabletr=$dom->find('table[id=Table6] tr');foreach($tabletr as $k=>$tr){ foreach($tr->find('td') as $k1=>$td){ if($k1!==0){ $info[$k][$k1]=$td->text(); } }}//优化数据foreach($info as $k=>$v){ if($k==1){ unset($info[1]); } if(count($v)==8){ unset($v[1]); } $info[$k]=array_values($v);}$week=$info[0];unset($info[0]);//组织数据foreach($info as $v){ foreach($v as $k=>$v){ $tmp[$week[$k]][]=$v; }}$res['info']=$tmp;echo "";";print_r($res);echo "";/*Array( [name] => 王峰 [info] => Array ( [星期一] => Array ( [0] => [1] => [2] => 线性代数B1-17(3,4)王黎峰电教楼205计科14(1) [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期二] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期三] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期四] => Array ( [0] => [1] => [2] => 线性代数B1-17(3,4)王黎峰电教楼205计科14(1) [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期五] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期六] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => ) [星期日] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => ) ))*///根据你自己的需求来处理课程信息$txt = <<";print_r($arr);echo "