php - how to split the contents when finding the elements -
i'm working on php i'm using simple_html_dom find list of elements i'm looking before splitting contents separate.
here output:
<?xml version='1.0' encoding='utf-8' ?> <tv generator-info-name="www.mysite.com/test"> <p id='channels'>101 abc family</p> <p id='channels'>102 cbs</p> <p id='channels'>103 cnn usa</p> <p id='channels'>105 espn usa</p> <p id='channels'>106 fox news</p> <p id='channels'>107 animal planet</p>
i want split contents 2 different variables 1 numbers , other 1 channels.
i want split numbers this:
101 102 103 105 106 107
and want split channels:
abc family cbs cnn usa espn usa fox news animal planet
here php
<?php ini_set('max_execution_time', 300); $errmsg_arr = array(); $errflag = false; $link; include ('simple_html_dom.php'); $xml = "<?xml version='1.0' encoding='utf-8' ?>"; $xml = '<tv generator-info-name="www.mysite.com/test">'; $base1 = "http://www.mysite.com/get-listing.php"; $html = file_get_html($base1); foreach($html->find('p[id=channels]') $element) { echo $xml; echo $element; } ?>
can tell me how can split contents want allow me use 2 different variables 1 numbers , other 1 channels?
foreach($html->find('p[id=channels]') $element) { $channelstr = $element->innertext; preg_match('/(\d+) (.*)/', $channelstr, $matches); echo $matches[1]; echo $matches[2]; }
Comments
Post a Comment