Jump to content

branmh

New Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About branmh

  • Rank
    Newbie
  1. branmh

    preg_match_all

    at the end of things I need to be able to set them as variables array_push($history_date, $m[1][$i]); Now how to only use the 17 <td>'s and not all the td's in that webpage? How can I make sure it using only the information between the <div id="obs-site"> </div>?
  2. branmh

    preg_match_all

    after I remove all the format from the html code (no spaces or tabs) and using <td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n<td>(.*)<\/td>\n It works. but how would I use it with the spaces or tabs?
  3. branmh

    preg_match_all

    that would be \n correct? I tried to but it doesn't work. just testing with <tr> <td>test</td> <td>test2</td> </tr> and <td>(.*)<\/td>\n<td>(.*)</td> it returns nothing until I add \n\s and then It returns but when I add 17 <td>(.*)<\/td>\n\s together i doesn't work. I need everything between the <tr></tr> setup for an array to set for different variables.
  4. branmh

    preg_match_all

    I'm having issues with preg_match_all, my information I used changed and doesn't match the previous code it was using. The table below is only showing 2 row's but it does contain about 30 row's. I have also attached the old code for reference. I just don't understand why or how to put a new line in between the <td></td>'s. if (preg_match_all('/<td>(\d+)<\/td><td.+?>([\d\:]+)<\/td><td>([\w\d\s]+)<\/td><td>([\d\.]+)<\/td><td.+?>([^,\n]+)<\/td>' . '<td>([^,\n]+)<\/td><td>(-?\d+)<\/td><td>(-?\d+)<\/td>' . '\s+?<td>(?-?\d+)|)<\/td><td>(?-?\d+)|)<\/td>' . '<td>([\d]+\%)<\/td><td>(NA|[\d\.]+)<\/td><td>(NA|[\d\.]+)<\/td><td>([\d\.]+)<\/td>' . '<td>(NA|[\d\.]+)<\/td><td>(|\d+\.\d+)<\/td><td>(|\d+\.\d+)<\/td><td>(|\d+\.\d+)<\//s', $raw, $m)) { <div id="obs-site"> <table class="data-table" cellpadding=0 cellspacing=0 border=0> <tr> <td>Apr 27 18:53</td> <td>E 10</td> <td>10</td> <td>Clear</td> <td>CLR</td> <td>77</td> <td>60</td> <td> </td> <td> </td> <td>56%</td> <td> </td> <td>77</td> <td>29.7</td> <td>29.7</td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Apr 27 17:53</td> <td>ESE 8</td> <td>10</td> <td>Clear</td> <td>CLR</td> <td>79</td> <td>59</td> <td> </td> <td> </td> <td>50%</td> <td> </td> <td>79</td> <td>29.71</td> <td>29.71</td> <td> </td> <td> </td> <td> </td> </tr> </table> </div>
  5. branmh

    JSON to PHP variables

    I have to assign variables in my php fie to use in my template.
  6. branmh

    JSON to PHP variables

    Thanks, with the key it would have another name in front of it to prevent overwrites. But there isn't a way to save everything to variables? So how would I be able to use https://api.weather.gov/stations/KAMA/observations, when it as multiple nodes named the same but different data?
  7. Having an issue within the <description> node, it contains a header line and then followed by <![CDATA[ story paragraph [/size]]]>. How to create another variable for everything inside the CDATA? and/or how to remove that entirely? Thanks in advance. //this remove all a href from rawdata $rawdata = preg_replace('@<a href=[^>]+>(.*)</a>@', '', $rawdata); $rawdata = preg_replace('/<pre>/', '', $rawdata); $rawdata = preg_replace('/<\/pre>/', '', $rawdata); $rss_update = preg_match_all("/<pubDate>(.*)<\/pubDate>/", $rawdata, $rss_update); $types = array( 'link', 'description', 'title', 'pubDate', 'author'); $valid = array(); $link = $description = $title = $pubDate = $author = array(); $rawdata = preg_replace('/<item>/', "<item>\s", $rawdata); if (preg_match_all('/<item>(.+?)<\/item>/s', $rawdata, $r)) { $rr = count($r[0]); for ($i = 0; $i < $rr; $i++) { if (preg_match_all('/<(.+?)>(.+?)<\//s', $r[1][$i], $y)) { $yy = count($y[0]); for ($x = 0; $x < $yy; $x++) { if (in_array($y[1][$x], $types)) { array_push(${$y[1][$x]}, $y[2][$x]); } } } } } if ($this->debug) echo "rss total $i\n"; $this->smarty->assign('rss_update', $rss_update); $this->smarty->assign('rss_link', $link); $this->smarty->assign('rss_description', $description); $this->smarty->assign('rss_title', $title); $this->smarty->assign('rss_pubdate', $pubDate); $this->smarty->assign('rss_author', $author); $this->smarty->assign('rss_story', $story); $this->smarty->assign('rss_total', $i);
  8. branmh

    JSON to PHP variables

    I new to using JSON and PHP. I need some help on how to convert it over to a php array of variables. I want to take this file https://api.weather.gov/stations/KAMA/observations/current and convert it over. Is it possible to put everything into variables? I'm able to see the entire json with this code $json_ary = json_decode($file,true); foreach($json_ary as $key => $val) { //echo "$key<br>\n"; foreach ($val as $key2 => $val2) { echo "... $key2 => $val2<br>\n"; foreach ($val2 as $key3 => $val3) { echo "... $key3 => $val3<br>\n"; } } } But it's not returning what I'm wanting. Like on temperature, I would like the value to automatically assigned to temperature. If you can help that would be greatly appreciated. At the beginning of the week I lost my friend that helps me out on this stuff and I'm so lost.
×

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.