Advertisement
bejiitas_wrath

PHP foreach loop.

Nov 9th, 2022
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. $radio = file_get_contents("https://i.mjh.nz/au/$stations/radio.json");
  4.  
  5. if(!empty($radio)) {
  6. printf("<p>Radio stations in %s.</p><br />\n", $stations);
  7. }
  8.  
  9. $json = json_decode($radio, true);
  10.  
  11. foreach ($json as $key => $value) {
  12.  
  13. if($val = 0)
  14. continue;
  15.  
  16. if (!is_array($value)) {
  17. echo '<p>', $key . '=>' . $value . '</p>';
  18. } else {
  19. foreach ($value as $key => $val) {
  20. //echo '<p>', $key . '=>' . $val . '</p>';
  21. if ($key == "logo") {
  22. echo '<img src="', $val . '" width="24" alt=""/>';
  23. }
  24. if ($key == "name") {
  25. echo '<p>', $val . '&nbsp;';
  26. }
  27. if ($key == "mjh_master") {
  28. echo '&nbsp;URL: ', '<a href="' . $val . '">' . $val .'</a>' . '</p>';
  29. echo '<hr noshade style="'. $class .'"/>';
  30. }
  31. }
  32. }
  33. }
  34.  
  35. ?>
  36. </div>
Tags: php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement