Jump to content

branmh

New Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by branmh

  1. I have to assign variables in my php fie to use in my template.
  2. 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?
  3. 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);
  4. 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.
×
×
  • 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.