开发者

reading a webpage html source code and adding table into arrays with php

im trying to 开发者_运维问答read a webpage's source code and add an information of a table into arrays

The webpage is http://dsrd.uc.cl/dara/libcursos/periodo21/ua5_1.html

Within the table, i want to add the column "profesores" into an array profesores[] and the column "nombre asignatura" into an array curso[];

I know I can get the webpage source coude with:

$homepage = file_get_contents('http://www.example.com/');

but I have no idea into how to manage the string to create the arrays.


One way would be to use DOMDocument:

$doc = new DOMDocument();
$doc->loadHTML($homepage);
$table = $doc->getElementsByTagName("table")->item(/* Find out which one it is */)
$rows = $table->getElementByTagName("tr")
for ($i = 0; $i length; $i++)
{
    $row = $rows->item($i);
    /* Find columns and add it to your array */
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜