php - How to split the string seperate in one contet -


i'm working on php parse contents i'm using simple_html_dom. want split strings between time , programme title.

here strings:

2:00 pm                                               local programming 

i want split strings separate make this:

<span id="time1">2:00 pm </span> - <span id="title1">local programming</span> 

here php:

<?php $links = $row['links']; $html = file_get_html($links);  $base = $row['links'];  $curl = curl_init(); curl_setopt($curl, curlopt_ssl_verifypeer, false); curl_setopt($curl, curlopt_header, false); curl_setopt($curl, curlopt_followlocation, true); curl_setopt($curl, curlopt_url, $base); curl_setopt($curl, curlopt_referer, $base); curl_setopt($curl, curlopt_returntransfer, true); $str = curl_exec($curl); curl_close($curl);  // create dom object $html = new simple_html_dom(); // load html string $html->load($str);  if ($html->find('li[id=row1-24]', 0) == true) {   $title1 = $html->find('li[id=row1-24]', 0)->plaintext; // }  echo $title1; ?> 

can please tell me how can split strings 2 different variables can output them in php?

how this?

$title1 = preg_split("/ {4,}/",$title1); echo '<span id="time1">' . $title1[0] . '</span> - <span id="title1">' . $title1[1] . '</span>'; 

this splits string array on 4 or more spaces.

the returned array has 2 items in this: ["2:00 pm","local programming"].

then uses array create desired html markup , echos it.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -