Jump to content

mark107

Members
  • Posts

    113
  • Joined

  • Last visited

Everything posted by mark107

  1. You heard me. Yes of course I do, I want to fetch the elements from the ID "Streams" for each channel. I have got two different href value which there are <a id="link1" and <a id="streams". Each channel I have as it have got the same ID "Streams" but it come with each different link, example: rtmp://www.testserver.com/bbc1, rtmp://www.testserver.com/bbc2...etc. When I try this: $streams_url = $domdoc->getElementsByTagName('a'); foreach($streams_url as $a) { $url[0] = $a->getAttribute("href"); print_r($url); } I will get the full elements from the both html tags <a id="link1" and <a id="streams". Here is the output: Array ( [0] => http://myserverip/get-listing.php?channels=BBC One S East&id=101 ) Array ( [0] => rtmp://www.testserver.com/bbc1 ) Array ( [0] => http://myserverip/get-listing.php?channels=BBC Two&id=102) Array ( [0] => rtmp://www.testserver.com/bbc2 ) Array ( [0] => http://myserverip/get-listing.php?channels=ITV&id=103 ) Array ( [0] => rtmp://www.testserver.com/itv1 ) Array ( [0] => http://myserverip/get-listing.php?channels=Channel 4&id=104 ) Array ( [0] => rtmp://www.testserver.com/channel4 ) Array ( [0] => http://myserverip/get-listing.php?channels=Channel 5&id=105 ) Array ( [0] => rtmp://www.testserver.com/channel5 ) Array ( [0] => http://myserverip/get-listing.php?channels=Sky One&id=106 ) Array ( [0] => rtmp://www.testserver.com/skyone ) Array ( [0] => http://myserverip/get-listing.php?channels=Sky Living&id=107 ) Array ( [0] => rtmp://www.testserver.com/skyliving ) Array ( [0] => http://myserverip/get-listing.php?channels=Sky Atlantic&id=108 ) Array ( [0] => rtmp://www.testserver.com/skyatlantic ) Here is the full code: <?php ini_set('max_execution_time', 300); //error_reporting(0); $errmsg_arr = array(); $errflag = false; function getState($string) { $ex = explode(" ",$string); return $ex[1]; } $baseUrl = file_get_contents('http://myserverip/get-listing.php'); $domdoc = new DOMDocument(); $domdoc->strictErrorChecking = false; $domdoc->recover=true; $domdoc->loadHTML($baseUrl); $streams_url = $domdoc->getElementsByTagName('a'); foreach($streams_url as $a) { $url[0] = $a->getAttribute("href"); print_r($url); } ?> What I want to achieve is I want to get the elements from the ID "Streams" tags to make it show like this: Array ( [0] => rtmp://www.testserver.com/bbc1 ) Array ( [0] => rtmp://www.testserver.com/bbc2 ) Array ( [0] => rtmp://www.testserver.com/itv1 ) Array ( [0] => rtmp://www.testserver.com/channel4 ) Array ( [0] => rtmp://www.testserver.com/channel5 ) Array ( [0] => rtmp://www.testserver.com/skyone ) Array ( [0] => rtmp://www.testserver.com/skyliving ) Array ( [0] => rtmp://www.testserver.com/skyatlantic ) Do you know what is the best way I could use to parse the elements from the tag from the ID "Streams" while ignore the elements from the other tag??
  2. Yes I have fixed the issues and I have forgot to add the xpath to definte it. I want to parse the element from one of these hyperlink. Here there are two different hyperlinks: <a id="link1" href="http://myserverip/getlisting.php?channel=skyatlantic">http://myserverip/getlisting.php?channel=Sky Atlantic&id=108</a> <a id="streams" href="rtmp://www.testserver.com/skyatlantic">Stream 1</a> I want to parse the element from the tag called "streams". When I try this: $xpath = new DOMXpath($domdoc); $el = $domdoc->getElementById('streams'); $url = $el->getAttribute('href'); //$streams_url = $xpath->query('//[@id="streams"]'); echo $url; It will only let me to parse one of these element as I have got more than one element in my html code. Do you know how i could parse each element from each streams tags??
  3. Sorry I have make a mistake with my code. I can see there is no span tag as I am using the <a id tags so do you know how I could parse the <a id tag to get the element from the href?? Here is where you can see it: <a id="streams" href="rtmp://www.testserver.com/skyatlantic">Stream 1</a>
  4. Hi guys, I need some help with my code. I want to parse each element from the streams tags but I cant find out how I could do this. When I try this: $streams_url = $xpath->query("//span[@id='streams'"]); echo $streams_url; I will get something like this: serverip page isn’t working serverip is currently unable to handle this request. HTTP ERROR 500 Here is the php: <?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; function getState($string) { $ex = explode(" ",$string); return $ex[1]; } $baseUrl = file_get_contents('http://myserverip/get-listing.php'); $domdoc = new DOMDocument(); $domdoc->strictErrorChecking = false; $domdoc->recover=true; @$domdoc->loadHTML($baseUrl); $links = $domdoc->getElementsByTagName('a'); $i = 0; $count = 0; $streams_url = $xpath->query("//span[@id='streams'"]); echo $streams_url; $data = array(); foreach($links as $link) { if($link->getAttribute('href')) { } } >? Here is the html data: <a id="link1" href="http://myserverip/getlisting.php?channel=skyatlantic">http://myserverip/getlisting.php?channel=Sky Atlantic&id=108</a><br><br><a id="streams" href="rtmp://www.testserver.com/skyatlantic">Stream 1</a> Here is what I want to achieve: rtmp://www.testserver.com/skyatlantic I want to parse each element from the streams tags. Can you please show me how i could do this in PHP??
  5. How I can open the htaccess to change the policies to allow me to download the Myxmlfilename.xml? I have no idea how to open the htaccess.
  6. Hi guys, I need your help. I have .xml file in download directory on my server. whoever visit my site page (Myxmlfilename.xml) user should be able to download these files and other files should not. I am trying to achieve above but no luck... does anyone know how I can access to Myxmlfilename.xml to download the xml file? thank you in advance.
  7. I'm showing you the output of the xml tree, can you see at the <title lang="en"></title> where each of them I'm getting the same strings called "Reba - Meet the Parents"? do you know how I can output each of these strings from the arrays like this? The Middle - The Telling The Middle - The Wedding Melissa & Joey - More Than Roommates Melissa & Joey - Accidents Will Happen Melissa & Joey - Right Time, Right Place Baby Daddy - Curious Georgie John Tucker Must Die(D,L,V,S) The 700 Club Baby Daddy - From Here to Paternity Reba - Meet the Parents
  8. Hi all, I need your help as I got a problem with the strings. When I get the list of strings for the input, I keep getting the same strings over and over when I output them. Here is what you can see in the output: <tv generator-info-name="www.mysite.com/xmltv"> <channel id="101 ABC FAMILY"> <display-name>101 ABC FAMILY</display-name> <programme channel="101 ABC FAMILY" start="20140507180000" stop=" 20140507183000"> <title lang="en">Reba - Meet the Parents</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507183000" stop=" 20140507190000"> <title lang="en">Reba - Meet the Parents</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507190000" stop=" 20140507193000"> <title lang="en">Reba - Meet the Parents</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507193000" stop=" 20140507200000"> <title lang="en">Reba - Meet the Parents</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507200000" stop=" 20140507203000"> <title lang="en">Reba - Meet the Parents</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507203000" stop=" 20140507210000"> <title lang="en">Reba - Meet the Parents</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> </tv> It supposed to be what it would look like: <tv generator-info-name="www.mysite.com/xmltv"> <channel id="101 ABC FAMILY"> <display-name>101 ABC FAMILY</display-name> <programme channel="101 ABC FAMILY" start="20140507180000" stop=" 20140507183000"> <title lang="en">he Middle - The Telling</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507183000" stop=" 20140507190000"> <title lang="en">he Middle - The Wedding</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507190000" stop=" 20140507193000"> <title lang="en">Melissa & Joey - More Than Roommates</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507193000" stop=" 20140507200000"> <title lang="en">Melissa & Joey - Accidents Will Happen</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507200000" stop=" 20140507203000"> <title lang="en">Melissa & Joey - Right Time, Right Place</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140507203000" stop=" 20140507210000"> <title lang="en">Baby Daddy - Curious Georgie</title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> </tv> Here is the input: The Middle - The Telling The Middle - The Wedding Melissa & Joey - More Than Roommates Melissa & Joey - Accidents Will Happen Melissa & Joey - Right Time, Right Place Baby Daddy - Curious Georgie John Tucker Must Die(D,L,V,S) The 700 Club Baby Daddy - From Here to Paternity Reba - Meet the Parents Here is the PHP: <?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; function getState($string) { $ex = explode(" ",$string); return $ex[1]; } $xml .= '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= ' <tv generator-info-name="www.mysite.com/xmltv">'; $baseUrl = file_get_contents('http://www.myownsite.com/get-listing.php' ); $domdoc = new DOMDocument(); $domdoc->strictErrorChecking = false; $domdoc->recover=true; @$domdoc->loadHTML($baseUrl); $links = $domdoc->getElementsByTagName('a'); $i = 0; $count = 0; $data = array(); foreach($links as $link) { if($link->getAttribute('href')) { if(!$link->hasAttribute('id') || $link->getAttribute('id')!='streams') { $url = str_replace("rtmp://", "", $link->getAttribute('href')); $url = str_replace(" ", "%20", $link->getAttribute('href')); $sdoc = new DOMDocument(); $sdoc->strictErrorChecking = false; $sdoc->recover=true; @$sdoc->loadHTMLFile($url); $query = parse_url($url)['query']; $channel_split = explode("&", $query)[0]; $channel = urldecode(explode("=",$channel_split)[1]); $id_split = explode("&", $query)[1]; $my_id = urldecode(explode("=",$id_split)[1]); $xpath = new DOMXpath($sdoc); $programme_arr = array(); $time_arr = array(); for ($i = 1; $i < 70; $i++) { $time_arr[] = $xpath->query("*/span[@id='time".$i."']"); $programme_arr[] = $xpath->query("*/span[@id='title".$i."']"); } foreach($programme_arr as $programme) { $programme1 = $programme->item(0)->nodeValue; } $programme_title = $programme1; // Generating to make the XML File $xml .= " <channel id='" . $my_id. " " . $channel . "'>"; $xml .= " <display-name>" . $my_id. " " . $channel; $xml .= " </display-name>"; // Save the output format $DATE_FORMAT_STRING = "YmdHis"; // GET the current STAGE $current_state = getState($array[0]->nodeValue); $offset = 0; $flag = 0; foreach($time_arr as $time) { // Get the item state. $this_state = getState($time->item(0)->nodeValue); // check if we past a day? if($current_state == "PM" && $this_state == "AM") { $offset++; } $this_unix = strtotime($time->item(0)->nodeValue) + (60 * 60 * 24 * $offset); $values[] = date($DATE_FORMAT_STRING, $this_unix); $starttime = $values[$count]; if($flag>0) { $xml .= ' <programme channel="'.$my_id. ' ' .$channel.'" start="'.$stoptime.'" stop="'.$starttime.'">'; $xml .= '<title lang="en">'.$programme_title; $xml .= ' </title>'; $xml .= ' <sub-title lang="en">'; $xml .= ' </sub-title>'; $xml .= ' <desc lang="en">'; $xml .= ' </desc>'; $xml .= ' <category lang="en">'; $xml .= ' </category>'; $xml .= ' </programme>'; $stoptime = $starttime; } else { $stoptime = $starttime; $flag=1; } $current_state = $this_state; $count++; } $xml .= ' </channel>'; } } } $xml .= ' </tv>'; // output the xml to the browser in this example, write $xml to a file here... header("Content-Type: text/xml"); echo $xml; $handle = fopen("myChannel.xml", "w"); fwrite ($handle, $xml); ?> Can you please tell me how I can get each strings to output them without output the same strings?
  9. it still don't work for me, please see it here: http://67.23.248.61/~ytestbox/test_xml.php here is the update code: <?php $my_id = '101'; $channel = 'ABC FAMILY'; $starttime = '2014-05-04'; $stoptime = '2014-05-05'; $xml .= '<programme channel=\'' .$channel. '\'>'; //$xml .= "<programme channel='".$channel."' start='".$starttime."'>"; //$xml .= "<programme channel='$my_id $channel' start='$starttime' stop='$stoptime'>"; $xml .= '</programme>'; header("Content-Type: text/xml"); echo $xml; $handle = fopen("myChannel.xml", "w"); fwrite ($handle, $xml); ?>
  10. thanks Ch0cu3r, but the code you have post the single quotes are still not showing because i'm still using the string delimiter. Any idea?
  11. Because it is my script and it is my own work to use so it does bother me!!! so how to add the single quote in the <programme channel= tag because on mine mine it will be showing without the quote like this: <programme channel=ABC FAMILY></programme> here is the code: $xml .= '<programme channel=' .$channel. '>';
  12. I'm working on my php as I'm generating to make the xml output. I need some help with my php as I want to add the single quotes in the <programme channel= tag to make it like this: <programme channel='101 ABC FAMILY' start='20140504113000' stop='20140504131000'> On mine the output show like this: <programme channel="101 ABC FAMILY" start="20140504113000" stop="20140504131000"> The problem are lie in this line: $xml .= " <programme channel='$my_id $channel' start='$stoptime' stop='$starttime'>"; Can you please tell me how i can make the output with the single quotes instead of using double quotes?
  13. I need some help with my PHP, I'm working on my PHP to parsing the contents from the elements. I have the ids of `<span id="time1">` and `<span id="title1">` for the elements. I'm trying to parse the `time1`, `time2`, `time3`, `time4`, `time5`, `time6`, `time7`, `time8`, `time9` and `title1`, `title2`, `title3`, `title4`, `title5`, `title6`, `title7`, `title8`, `title9` elements which I'm using `span` as the id. I will get the input of the `time1`, `time2`, `time3`, `time4`, `time5`, `time6`, `time7`, `time8`, `time9` and `title1`, `title2`, `title3`, `title4`, `title5`, `title6`, `title7`, `title8`, `title9` together which I want to get the list of `time1` to `time9` and `title1` to `title9` in separate. Here is the input: 7:00 PMMelissa & Joey - Born to Run7:30 PMMelissa & Joey - More Than Roommates8:00 PMMelissa & Joey - Accidents Will Happen8:30 PMBaby Daddy - From Here to Paternity9:00 PM Here is the output of get-listing: <span id="time1">7:00 PM</span> - <span id="title1">Melissa & Joey - Born to Run</span><br></br> <span id="time2">7:30 PM</span> - <span id="title2">Melissa & Joey - More Than Roommates</span><br></br> <span id="time3">8:00 PM</span> - <span id="title3">Melissa & Joey - Accidents Will Happen</span><br></br> <span id="time4">8:30 PM</span> - <span id="title4">Baby Daddy - From Here to Paternity</span><br></br> <span id="time5">9:00 PM</span> Here is the code: <?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; $xml .= '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= ' <tv generator-info-name="www.mysite.com/xmltv">'; $baseUrl = file_get_contents('http://www.mysite.com/get-listing.php'); $domdoc = new DOMDocument(); $domdoc->strictErrorChecking = false; $domdoc->recover=true; //@$domdoc->loadHTMLFile($baseUrl); @$domdoc->loadHTML($baseUrl); //$links = $domdoc->getElementsByTagName('test'); //$links = $domdoc->getElementById('test'); $links = $domdoc->getElementsByTagName('a'); $data = array(); foreach($links as $link) { //echo $domdoc->saveXML($link); if($link->getAttribute('href')) { if(!$link->hasAttribute('id') || $link->getAttribute('id')!='streams') { $url = str_replace("rtmp://", "", $link->getAttribute('href')); $url = str_replace(" ", "%20", $link->getAttribute('href')); //echo $url; //echo "<br>"; $sdoc = new DOMDocument(); $sdoc->strictErrorChecking = false; $sdoc->recover=true; @$sdoc->loadHTMLFile($url); $spans = $sdoc->getElementsByTagName('span'); $query = parse_url($url)['query']; $channel_split = explode("&", $query)[0]; $channel = urldecode(explode("=",$channel_split)[1]); $id_split = explode("&", $query)[1]; $my_id = urldecode(explode("=",$id_split)[1]); //echo $my_id; //echo '<channel id='.$my_id.'>'; //echo $spans->nodeValue; $flag=0; foreach($spans as $span) { echo $span->nodeValue; $starttime=$span->nodeValue; //echo "<programme channel='".$my_id." ".$channel." start='".$starttime."' stop='".$stoptime."'>"; if($flag>0) { //echo "<programme channel='".$my_id." ".$channel." start='".$starttime."' stop='".$stoptime."'>"; $stoptime=$starttime; $flag=1; } else { $stoptime=$starttime; } } } } } ?> Can you please tell me how I can create the arrays for the domdocument to get the element id of `time1` to `time9` to make it separate with `title1` to `title9`?
  14. Thank you very much for that, I can see it is working now. Cheers for the help!!!
  15. cyberRobot: yeah so how I can only get the links with href without getting the aTest id?
  16. I need some help with my PHP, I'm to parsing the href contents using DOMDocument. I have the list of url that I'm parsing only for the website link even I want to ignore the `<a id="aTest" href="` tags. Here is the input: http://www.mysite.com/get-listing.php?channels=test 1&id=101 http://www.mysite.com/get-listing.php?channels=test 2&id=102 http://www.mysite.com/get-listing.php?channels=test 3&id=103 rtmp://$OPT:rtmp-raw=rtmp://ny.iguide.to/edge playpath=49f5xnbs2wra0ut swfUrl=http://player.ilive.to/player_ilive_2.swf pageUrl=http://www.ilive.to token=UYDk93k#09sdafjJDHJKAD873 Here is the output: <a href='http://www.mysite.com/get-listing.php?channels=test 1&id=101'></a></p><a id="aTest" href="">Stream 1</a><br><br> <a href='http://www.mysite.com/get-listing.php?channels=test 2&id=102'></a></p><a id="aTest" href="">Stream 1</a><br><br> <a href='http://www.mysite.com/get-listing.php?channels=test 3&id=103'></a></p><a id="aTest" href="rtmp://$OPT:rtmp-raw=rtmp://ny.iguide.to/edge playpath=49f5xnbs2wra0ut swfUrl=http://player.ilive.to/player_ilive_2.swf pageUrl=http://www.ilive.to token=UYDk93k#09sdafjJDHJKAD873">Stream 1</a><br><br> Here is the PHP: <?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; $xml .= '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= ' <tv generator-info-name="www.mysite.com/xmltv">'; $baseUrl = file_get_contents('http://www.mysite.com/get-listing.php'); $domdoc = new DOMDocument(); $domdoc->strictErrorChecking = false; $domdoc->recover=true; //@$domdoc->loadHTMLFile($baseUrl); @$domdoc->loadHTML($baseUrl); $links = $domdoc->getElementsByTagName('a'); $data = array(); foreach($links as $link) { //echo $domdoc->saveXML($link); if($link->getAttribute('href')) { $url = str_replace(" ", "%20", $link->getAttribute('href')); $url = str_replace("rtmp://", "", $link->getAttribute('href')); } } ?> Can you please tell me how I can parsing the contents as only for `<a href='http://www.mysite.com/get-listing.php` while ignoring the other contents especially `<a id="aTest" href="`? Does anyone know how?
  17. I have got a problem with my PHP and I need your urgent help. I have the list of 3 urls where I'm sending the request to each url to get the hours so I will convert it to format. Example: I will get the hours of 7:30 AM, so I will convert them into this 20140426073000, for 9:30AM i will convert it to 20140426093000. For Url one input: 7:30 AM 9:30 AM For Url two input: 9:00 AM 11:00 AM For Url three input: 9:00 AM 10:00 AM In that way, when I send the request to each url to get the hours and converting the hours into format, I will get the three same input of format when I run through the loops. Here is the input: 20140426073000 20140426093000 20140426073000 20140426093000 20140426073000 20140426093000 It should be looks like this: 20140426073000 20140426093000 20140426009000 20140426011000 20140426090000 20140426100000 Here is the code: <?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; include ('simple_html_dom.php'); function getState($string) { $ex = explode(" ",$string); return $ex[1]; } $xml .= '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= ' <tv generator-info-name="www.mysite.com/xmltv">'; $base1 = "http://www.mysite.com/get-listing.php"; $html = file_get_html($base1); $i = 0; $count = 0; foreach($html->find('p[id=links]') as $element) { $program_list[ $count ] = array(); $id_split = explode("?", $element->plaintext); $id_split = explode("&", $link_split[1]); $channels = explode("channels=",$id_split[0]); $channels = $channels[1]; $id = explode("id=",$id_split[1]); $id = $id[1]; //channels //$channel_test = $html->find('p[id=channels]', 10)->plaintext; //echo $channel_test; $program_list[$count]['channels'] = $channels; $program_list[$count]['id'] = $id; $channels_split = explode("?", $element->plaintext); $channels_split = explode("&", $channels_split[1]); $channel_id = explode("channels=",$channels_split[0]); $channel_id = $channel_id[1]; $my_id = explode("id=",$channels_split[1]); $my_id = $my_id[1]; $channel = urlencode($channel_id); $id_1 = urlencode($my_id); $html_two = file_get_html("http://www.mysite.com/get-listing.php?channels=" . $channel . "&id=" . $my_id); $time1 = $html_two->find('span[id=time1]',0)->plaintext; $time2 = $html_two->find('span[id=time2]',0)->plaintext; $time3 = $html_two->find('span[id=time3]',0)->plaintext; $array = array( $time1, $time2, $time3, ); // Save the output format $DATE_FORMAT_STRING = "YmdHis"; // GET the current STAGE $current_state = getState($array[0]); $offset = 0; foreach($array as $time) { // Get the item state. $this_state = getState($time); // check if we past a day? if($current_state == "PM" && $this_state == "AM") { $offset++; } $this_unix = strtotime($time) + (60 * 60 * 24 * $offset); $values[] = date($DATE_FORMAT_STRING, $this_unix); //echo date($DATE_FORMAT_STRING, $this_unix); //echo "<br></br>"; } echo $values[0]; echo "<br>"; echo $values[1]; echo "<br></br>"; $current_state = $this_state; } ?> When I tried to get the time for each url that I send request to convert to format, I will get the same input of format when I run through the loops. Do you know how I can get each different format when I send the request to each url?
  18. Hi all, I need some help with my php script. I'm working on the script to parsing the time from my other script so I can convert the hours into format, example: the hours I parse is 1:00 AM so I can convert it to 20140427010000. Here is the list of format for 3 channels: 20140427010000 20140427013000 20140427020000 20140427023000 20140428063000 20140428070000 20140428103000 20140428133200 20140428170000 20140429120000 20140429123000 20140429130000 20140429133000 20140429140000 20140426210000 20140426220000 20140426230000 20140427000000 20140427003500 20140427013700 20140427023700 20140427070000 20140428000000 20140428013000 20140428050000 20140428060000 20140428070000 20140429000000 20140429030000 20140429060000 20140429063000 20140429070000 20140426210000 20140426220000 20140426223000 20140426230000 20140427000000 20140427010000 20140427013000 20140427020000 20140427030000 20140428000000 20140428010000 20140428020000 20140428030000 20140428040000 20140429000000 20140429010000 20140429020000 20140429030000 20140429040000 Here is the PHP: <?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; include ('simple_html_dom.php'); function getState($string) { $ex = explode(" ",$string); return $ex[1]; } $xml .= '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= ' <tv generator-info-name="www.mysite.com/xmltv">'; $base1 = "http://www.mysite.com/get-listing.php"; $html = file_get_html($base1); $i = 0; foreach($html->find('p[id=links]') as $element) { $program_list[ $count ] = array(); $id_split = explode("?", $element->plaintext); $id_split = explode("&", $link_split[1]); $channels = explode("channels=",$id_split[0]); $channels = $channels[1]; $id = explode("id=",$id_split[1]); $id = $id[1]; //channels //$channel_test = $html->find('p[id=channels]', 10)->plaintext; //echo $channel_test; $program_list[$count]['channels'] = $channels; $program_list[$count]['id'] = $id; $channels_split = explode("?", $element->plaintext); $channels_split = explode("&", $channels_split[1]); $channel_id = explode("channels=",$channels_split[0]); $channel_id = $channel_id[1]; $my_id = explode("id=",$channels_split[1]); $my_id = $my_id[1]; $channel = urlencode($channel_id); $id_1 = urlencode($my_id); $html_two = file_get_html("http://www.mysite.com/get-listing.php?channels=" . $channel . "&id=" . $my_id); $time1 = $html_two->find('span[id=time1]',0)->plaintext; $time2 = $html_two->find('span[id=time2]',0)->plaintext; $time3 = $html_two->find('span[id=time3]',0)->plaintext; $time4 = $html_two->find('span[id=time4]',0)->plaintext; $time5 = $html_two->find('span[id=time5]',0)->plaintext; $time6 = $html_two->find('span[id=time6]',0)->plaintext; $time7 = $html_two->find('span[id=time7]',0)->plaintext; $time8 = $html_two->find('span[id=time8]',0)->plaintext; $time9 = $html_two->find('span[id=time9]',0)->plaintext; $time10 = $html_two->find('span[id=time10]',0)->plaintext; $time11 = $html_two->find('span[id=time11]',0)->plaintext; $time12 = $html_two->find('span[id=time12]',0)->plaintext; $time13 = $html_two->find('span[id=time13]',0)->plaintext; $time14 = $html_two->find('span[id=time14]',0)->plaintext; $array = array( $time1, $time2, $time3, $time4, $time5, $time6, $time7, $time8, $time9, $time10, $time11, $time12, $time13, $time14, ); // Save the output format $DATE_FORMAT_STRING = "YmdHis"; // GET the current STAGE $current_state = getState($array[0]); $offset = 0; foreach($array as $time) { // Get the item state. $this_state = getState($time); // check if we past a day? if($current_state == "PM" && $this_state == "AM") { $offset++; } $this_unix = strtotime($time) + (60 * 60 * 24 * $offset); echo date($DATE_FORMAT_STRING, $this_unix); echo "<br></br>"; $current_state = $this_state; } } ?> I want to know how do you get each of those format to output them in the xml start="" and end="" like this? <?xml version="1.0" encoding="UTF-8" ?> <tv generator-info-name="www.mysite.com/XML"> <programme channel='test start='20140427010000' stop='20140427013000'> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"> </desc> <category lang="en"></category> </programme> <programme channel='test start='20140427013000' stop='20140427020000'> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"> </desc> <category lang="en"></category> </programme> <programme channel='test start='20140427020000' stop='20140427023000'> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"> </desc> <category lang="en"></category> </programme> <programme channel='test start='20140427023000' stop='20140428063000'> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"> </desc> <category lang="en"></category> </programme> <programme channel='test start='20140428063000' stop='20140428070000'> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"> </desc> <category lang="en"></category> </programme> </tv> I tried to use the values, but I will get the wrong format and the format will get mess up if I use the values. Does anyone know how I can get the format for per channel using with the values if that is possible?
  19. Because I'm parsing the time to output them in my script. If you don't understand what I want to achieve, here is for example: 10:00 AM 11:00 AM 12:00 PM 12:30 PM 2:00 PM 2:30 PM 3:00 PM 4:00 PM 5:30 PM 6:00 PM 7:00 PM 9:00 PM 11:00 PM 12:00 AM 12:30 AM 1:00 AM 1:30 AM 2:00 AM 11:00 PM 12:00 AM 12:30 AM 1:00 AM These are the time that I'm parsing to output them in my script, so I want to convert these time into format to make it like this: 20140424100000 20140424110000 20140424120000 20140424123000 20140424140000 20140424143000 20140424210000 20140424230000 20140425000000 20140425003000 20140425010000 20140425013000 20140425020000 20140425230000 20140426000000 20140426003000 20140426010000 Here is the output: <span id="time1">10:00 AM</span> <span id="time2">11:00 AM</span> <span id="time3">12:00 PM</span> <span id="time4">12:30 PM</span> <span id="time5">2:00 PM</span> <span id="time6">2:30 PM</span> <span id="time7">9:00 PM</span> <span id="time8">11:00 PM</span> <span id="time9">12:00 AM</span> <span id="time10">12:30 AM</span> <span id="time11">1:00 AM</span> <span id="time12">1:30 AM</span> <span id="time13">2:00 AM</span> <span id="time14">11:00 PM</span> <span id="time15">12:00 AM</span> <span id="time16">12:30 PM</span> <span id="time17">1:00 AM</span> Can you please tell me how to convert these time into format when parsing the time?
  20. I need some help with set up the date format. I'm still trying to find out how I can set up the format to the next day, the day two and the day three date when I work out with the hours. Example: I set up the date format from today and the time is 10:00 AM, 11:00 AM, 12:00 PM, the format is 20140424100000, 20140424110000, 20140424120000 and so on until when I reaction to the 12:00 AM, I want to set up the format to the next day 20140425000000, 20140425003000, 20140425020000, 20140425023000 until when I reaction to the next 12:00 AM I want to set up the new format to the day two 20140426000000, 20140426003000, 20140426010000. My problem is when I'm parsing the list of time strings from my script, how I can work out the format with the date and the time? Here is the PHP: <?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; include ('simple_html_dom.php'); foreach($html->find('p[id=links]') as $element) { $program_list[ $count ] = array(); $id_split = explode("?", $element->plaintext); $id_split = explode("&", $link_split[1]); $channels = explode("channels=",$id_split[0]); $channels = $channels[1]; $id = explode("id=",$id_split[1]); $id = $id[1]; $html_two = file_get_html("http://www.mysite.com/myscript.php?getime); //time1 $time1 = $html_two->find('span[id=time1]',0)->plaintext; $hoursMinutes = explode(":", $time1[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; $time1 = explode(" ", $time1); $hoursMinutes = explode(":", $time1[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; //time2 $time2 = $html_two->find('span[id=time2]',0)->plaintext; $hoursMinutes = explode(":", $time2[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; $time2 = explode(" ", $time2); $hoursMinutes = explode(":", $time2[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; //time3 $time3 = $html_two->find('span[id=time3]',0)->plaintext; $hoursMinutes = explode(":", $time3[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; $time3 = explode(" ", $time3); $hoursMinutes = explode(":", $time3[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; ?> Here is the time strings: 10:00 AM 11:00 AM 12:00 PM 12:30 PM 2:00 PM 2:30 PM 9:00 PM 11:00 PM 12:00 AM 12:30 AM 1:00 AM 1:30 AM 2:00 AM 11:00 PM 12:00 AM 12:30 AM 1:00 AM
  21. I'm writing a PHP to generating the time and date to output them in the XML. I have got a problem with the day date. For each 24 hours, I have the day date adding to the next day date, e.g. I have the 24 hours time 00, 01 with same following day date 19th of april, the next 24 hours the hours is 00, 01 with next following day date 20th of april and so on. On my XML output, you can see that some day date have been used in the wrong date for each hours. Here is for example what it supposed to be: <tv generator-info-name="www.site.com/XMLTV"> <channel id="101 ABC FAMILY"> <display-name>101 ABC FAMILY</display-name> <programme channel="101 ABC FAMILY" start="20140419143000" stop="20140419163000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140419163000" stop="20140419181500"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140420080000" stop="20140420100000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140420100000" stop="20140419120000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140420120000" stop="20140420143000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140420143000" stop="20140420161200"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140420161200" stop="20140420175700"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> As you can see in the XML output, 2014 is the year, 04 is the month and 19 and 20 is the day date of the month. You can see that i have some day date are wrong for each 24 hours. Here is my XML: <tv generator-info-name="www.site.com/XMLTV"> <channel id="101 ABC FAMILY"> <display-name>101 ABC FAMILY</display-name> <programme channel="101 ABC FAMILY" start="20140419143000" stop="20140419163000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140419163000" stop="20140419181500"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140420080000" stop="20140420100000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140420100000" stop="20140419120000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140419120000" stop="20140419143000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140419143000" stop="20140420161200"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140420161200" stop="20140420175700"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> I have attached for you to take a look at my code: http://pastebin.com/CxX08Etp I have spent some days to try to find the solution when I write the list of code to allow me to add the day date to the next day for each 24 hours, e.g: in one day i have the date 19 of april and the hours is 00, 01, 02 with the same following day date, the next day date is 20 of april and the hours is 00, 01, 02 with the same following day date and so on. Some hours I have got in the XML it will show the previous day date which it supposed to be show the next day date. I'm using simple_html_dom to allow me to parsing the list of strings from get-listing.php. Here is the list of time strings: 10:00 AM 12:30 PM 2:30 PM 4:30 PM 6:15 PM 8:00 PM 10:03 PM 12:30 AM 1:00 AM 5:30 AM 6:00 AM 7:30 AM 8:00 AM 10:00 AM 12:00 PM 2:30 PM 4:12 PM 5:57 PM 8:00 PM 10:00 PM 12:00 AM 12:30 AM I have been so frustrated and I can't be able to find out how to add the day date for each 24 hours. Does anyone know how I can add the day date to the next day date for each 24 hours?
  22. does anyone know????????
  23. Hi all, I need your help, I'm working on my php to get the list of contents from my get-listing.php script so I can generating the XML to output the contents into the XML. I have got a little bit of problem with output the contents. I'm still getting the same contents in the XML output for each channel when I generating the XML. Here is the XML: <tv generator-info-name="www.mysite.com/myXML"> <channel id="101 ABC FAMILY"> <display-name>101 ABC FAMILY</display-name> <programme channel="101 ABC FAMILY" start="20140418160000" stop="20140418163000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140418163000" stop="20140418170000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140418170000" stop="20140418173000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> </channel> <channel id="102 CBS"> <display-name>102 CBS</display-name> <programme channel="102 CBS" start="20140418160000" stop="20140418163000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="102 CBS" start="20140418163000" stop="20140418170000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="102 CBS" start="20140418170000" stop="20140418173000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> Here's the ABC Family programme info: 4:00 PM - Boy Meets World - Home 4:30 PM - Boy Meets World - My Best Friend's Girl 5:00 PM - The Middle - The Big Chill 5:30 PM - The Middle - Friends, Lies and Videotape Here's the CBS programme info: 4:00 PM - The Talk 5:00 PM - Let's Make a Deal 6:00 PM - Local Programming 8:30 PM - CBS Evening News With Scott Pelley As you can see that on both channel programme info, it have got different time in each array. On mine it will show the same programme time for both channels when I'm generating the XML. Here is what it supposed to be: <tv generator-info-name="www.mysite.com/myXML"> <channel id="101 ABC FAMILY"> <display-name>101 ABC FAMILY</display-name> <programme channel="101 ABC FAMILY" start="20140418160000" stop="20140418163000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140418163000" stop="20140418170000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="101 ABC FAMILY" start="20140418170000" stop="20140418173000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> </channel> <channel id="102 CBS"> <display-name>102 CBS</display-name> <programme channel="102 CBS" start="20140418160000" stop="20140418170000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="102 CBS" start="20140418170000" stop="20140418180000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> <programme channel="102 CBS" start="20140418180000" stop="20140418203000"> <title lang="en"></title> <sub-title lang="en"></sub-title> <desc lang="en"></desc> <category lang="en"></category> </programme> </tv> Here is the PHP: <?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; include ('simple_html_dom.php'); function getUrlFriendlyString($str) { // convert spaces to '-', remove characters that are not alphanumeric // or a '-', combine multiple dashes (i.e., '---') into one dash '-'. $str = ereg_replace("[-]+", "-", ereg_replace("[^a-z0-9-]", "", strtolower( str_replace(" ", "-", $str) ) ) ); return $str; } function getPaddedHour($hour, $meridian) { $ret = $hour; if ($meridian == 'AM' && $ret == 12) { $ret = 0; } else if ($meridian == 'PM' && $ret != 12) { $ret += 11; } if ($ret < 10) { $ret = '0'.$ret; } return $ret; } $xml .= '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= ' <tv generator-info-name="www.testbox.elementfx.com/test">'; $base1 = "http://www.mysite.com/get-listing.php"; $html = file_get_html($base1); //echo $xml; foreach($html->find('p[id=links]') as $element) { $program_list[ $count ] = array(); $id_split = explode("?", $element->plaintext); $id_split = explode("&", $link_split[1]); $channels = explode("channels=",$id_split[0]); $channels = $channels[1]; $id = explode("id=",$id_split[1]); $id = $id[1]; //channels //$channel_test = $html->find('p[id=channels]', 10)->plaintext; //echo $channel_test; $program_list[ $count ]['channels'] = $channels; $program_list[ $count ]['id'] = $id; $channels_split = explode("?", $element->plaintext); $channels_split = explode("&", $channels_split[1]); $channel_id = explode("channels=",$channels_split[0]); $channel_id = $channel_id[1]; $my_id = explode("id=",$channels_split[1]); $my_id = $my_id[1]; $channel = urlencode($channel_id); $id_1 = urlencode($my_id); $html_two = file_get_html("http://www.mysite.com/get-listing.php?channels=" . $channel . "&id=" . $my_id); //time1 $time1 = $html_two->find('span[id=time1]',0)->plaintext; $title1 = $html_two->find('span[id=title1]',0)->plaintext; $hoursMinutes = explode(":", $time1[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; $time1 = explode(" ", $time1); $hoursMinutes = explode(":", $time1[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; if($time1[1] == "PM") { $time1[0] = date("Ymd") . ((int)($hours) + 12) . $minutes . "00"; } else { if($hours=="12") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00"; } else if($hours=="1") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "01" . $minutes . "00"; } else if($hours=="2") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "02" . $minutes . "00"; } else if($hours=="3") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "03" . $minutes . "00"; } else if($hours=="4") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "04" . $minutes . "00"; } else if($hours=="5") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "05" . $minutes . "00"; } else if($hours=="6") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "06" . $minutes . "00"; } else if($hours=="7") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "07" . $minutes . "00"; } else if($hours=="8") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "08" . $minutes . "00"; } else if($hours=="9") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "09" . $minutes . "00"; } else if($hours=="10") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "10" . $minutes . "00"; } else if($hours=="11") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "11" . $minutes . "00"; } else if($hours=="24") { $time1[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00"; } else { $time1[0] = date("Ymd") . $hours . $minutes . "00"; } } $program_list[$count]['start_time1'] = $time1[0]; $program_list[$count]['title1'] = $title1; //time2 $time2 = $html_two->find('span[id=time2]',0)->plaintext; $title2 = $html_two->find('span[id=title2]',0)->plaintext; $time2 = explode(" ", $time2); $hoursMinutes = explode(":", $time2[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; if($time2[1] == "PM") { $time2[0] = date("Ymd") . ((int)($hours) + 12) . $minutes . "00"; } else { if($hours=="12") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00"; } else if($hours=="1") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "01" . $minutes . "00"; } else if($hours=="2") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "02" . $minutes . "00"; } else if($hours=="3") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "03" . $minutes . "00"; } else if($hours=="4") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "04" . $minutes . "00"; } else if($hours=="5") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "05" . $minutes . "00"; } else if($hours=="6") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "06" . $minutes . "00"; } else if($hours=="7") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "07" . $minutes . "00"; } else if($hours=="8") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "08" . $minutes . "00"; } else if($hours=="9") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "09" . $minutes . "00"; } else if($hours=="10") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "10" . $minutes . "00"; } else if($hours=="11") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "11" . $minutes . "00"; } else if($hours=="24") { $time2[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00"; } else { $time2[0] = date("Ymd") . $hours . $minutes . "00"; } } $program_list[$count]['end_time1'] = $time2[0]; $program_list[$count]['start_time2'] = $time2[0]; $program_list[$count]['title2'] = $title2; //time3 $time3 = $html_two->find('span[id=time3]',0)->plaintext; $title3 = $html_two->find('span[id=title3]',0)->plaintext; $time3 = explode(" ", $time3); $hoursMinutes = explode(":", $time3[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; if($time3[1] == "PM") { $time3[0] = date("Ymd") . ((int)($hours) + 12) . $minutes . "00"; } else { if($hours=="12") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00"; } else if($hours=="1") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "01" . $minutes . "00"; } else if($hours=="2") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "02" . $minutes . "00"; } else if($hours=="3") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "03" . $minutes . "00"; } else if($hours=="4") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "04" . $minutes . "00"; } else if($hours=="5") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "05" . $minutes . "00"; } else if($hours=="6") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "06" . $minutes . "00"; } else if($hours=="7") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "07" . $minutes . "00"; } else if($hours=="8") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "08" . $minutes . "00"; } else if($hours=="9") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "09" . $minutes . "00"; } else if($hours=="10") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "10" . $minutes . "00"; } else if($hours=="11") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "11" . $minutes . "00"; } else if($hours=="24") { $time3[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00"; } else { $time3[0] = date("Ymd") . $hours . $minutes . "00"; } } $program_list[$count]['end_time2'] = $time3[0]; $program_list[$count]['start_time3'] = $time3[0]; $program_list[$count]['title3'] = $title3; //time4 $time4 = $html_two->find('span[id=time4]',0)->plaintext; $title4 = $html_two->find('span[id=title4]',0)->plaintext; $time4 = explode(" ", $time4); $hoursMinutes = explode(":", $time4[0]); $hours = $hoursMinutes[0]; $minutes = $hoursMinutes[1]; if($time4[1] == "PM") { $time4[0] = date("Ymd") . ((int)($hours) + 12) . $minutes . "00"; } else { if($hours=="12") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00"; } else if($hours=="1") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "01" . $minutes . "00"; } else if($hours=="2") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "02" . $minutes . "00"; } else if($hours=="3") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "03" . $minutes . "00"; } else if($hours=="4") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "04" . $minutes . "00"; } else if($hours=="5") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "05" . $minutes . "00"; } else if($hours=="6") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "06" . $minutes . "00"; } else if($hours=="7") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "07" . $minutes . "00"; } else if($hours=="8") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "08" . $minutes . "00"; } else if($hours=="9") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "09" . $minutes . "00"; } else if($hours=="10") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "10" . $minutes . "00"; } else if($hours=="11") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "11" . $minutes . "00"; } else if($hours=="24") { $time4[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00"; } else { $time4[0] = date("Ymd") . $hours . $minutes . "00"; } } $program_list[$count]['end_time3'] = $time4[0]; $program_list[$count]['start_time4'] = $time4[0]; $program_list[$count]['title4'] = $title4; if (strpos($channel, '+') !== false) { $channel = str_replace('+', ' ', $channel); } //program 1# $xml .= " <channel id='" . $my_id. " " . $channel . "'>"; $xml .= " <display-name>" . $my_id. " " . $channel; $xml .= "</display-name>"; $xml .= " <programme channel='" . $my_id. " " . $channel . "' start='" . $program_list[$i]['start_time1'] . "' stop='" . $program_list[$i]['end_time1'] . "'>"; $xml .= ' <title lang="en">'; $xml .= ' </title>'; $xml .= ' <sub-title lang="en">'; $xml .= ' </sub-title>'; $xml .= ' <desc lang="en">'; $xml .= ' </desc>'; $xml .= ' <category lang="en">'; $xml .= ' </category>'; $xml .= " </programme>"; //program 2# $xml .= " <programme channel='" . $my_id. " " . $channel . "' start='" . $program_list[$i]['start_time2'] . "' stop='" . $program_list[$i]['end_time2'] . "'>"; $xml .= ' <title lang="en">'; $xml .= ' </title>'; $xml .= ' <sub-title lang="en">'; $xml .= ' </sub-title>'; $xml .= ' <desc lang="en">'; $xml .= ' </desc>'; $xml .= ' <category lang="en">'; $xml .= ' </category>'; $xml .= ' </programme>'; //program 3# $xml .= " <programme channel='" . $my_id. " " . $channel . "' start='" . $program_list[$i]['start_time3'] . "' stop='" . $program_list[$i]['end_time3'] . "'>"; $xml .= ' <title lang="en">'; $xml .= ' </title>'; $xml .= ' <sub-title lang="en">'; $xml .= ' </sub-title>'; $xml .= ' <desc lang="en">'; $xml .= ' </desc>'; $xml .= ' <category lang="en">'; $xml .= ' </category>'; $xml .= ' </programme>'; //program 4# $xml .= " <programme channel='" . $my_id. " " . $channel . "' start='" . $program_list[$i]['start_time4'] . "' stop='" . $program_list[$i]['end_time4'] . "'>"; $xml .= ' <title lang="en">'; $xml .= ' </title>'; $xml .= ' <sub-title lang="en">'; $xml .= ' </sub-title>'; $xml .= ' <desc lang="en">'; $xml .= ' </desc>'; $xml .= ' <category lang="en">'; $xml .= ' </category>'; $xml .= ' </programme>'; } $xml .= ' </tv>'; // output the xml to the browser in this example, write $xml to a file here... header("Content-Type: text/xml"); echo $xml; $handle = fopen("myChannel.xml", "w"); fwrite ($handle, $xml); ?> Does anyone know how I can get the list of contents for each channel when I'm generating the XML without output the same contents on both channels tags in the XML? I think I have missing with something especially the integer.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.