Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $html = file_get_contents('https://www.manila-airport.net/naia-departures-terminal-1'); //get the html returned from the following url
- $tableData = array();
- $pokemon_doc = new \DOMDocument();
- libxml_use_internal_errors(TRUE); //disable libxml errors
- if (!empty($html)) { //if any html is actually returned
- $pokemon_doc->loadHTML($html);
- libxml_clear_errors(); //remove errors for yucky html
- $pokemon_xpath = new \DOMXPath($pokemon_doc);
- $pokemon_row = $pokemon_xpath->query('//div[contains(@id,"flight_detail")]');
- $tempData = array();
- $data = array();
- $processData = array();
- $count = 0;
- $toPushItem = new \StdClass;
- foreach ($pokemon_row as $key => $row) {
- $data[] = $row->nodeValue;
- // unset($data[0]);
- // unset($data[1]);
- // unset($data[2]);
- // unset($data[3]);
- // unset($data[4]);
- }
- end($data);
- $key = key($data);
- for ($i = 0; $i != $key; $i++) {
- $count++;
- $tempData[] = $data[$i];
- for ($j = 2; $j < $key; $j +=3) {
- $tempDatas[] = $data[$j];
- }
- // if ($count == 2) {
- //
- // $toPushItem = $tempData[0];
- //// $toPushItem->Carrier = $tempData[1];
- //// $toPushItem->Destination = $tempData[2];
- //// $toPushItem->Departure = $tempData[3];
- //// $toPushItem->Status = $tempData[4];
- // $processData[] = $toPushItem;
- //
- // $count = 0;
- // $tempData = array();
- // $toPushItem = new \StdClass;
- // }
- }
- foreach ($tempDatas as $key => $data2){
- $buffer = str_replace(array("\n", ), ',', $data2);
- $buffer = str_replace(array(",,,",",," ), ',', $buffer);
- $string = trim($buffer,",");
- $x = preg_replace('/\s*,\s*/', ',', $string);
- $myArray[] = explode(',', $x);
- }
- print_r($myArray);exit;
- $json = json_encode($processData);
- $array = json_decode($json, true);
- print_r($tempData);exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement