0

I'm trying to make an array with all of the scheduled programming from 0000 until 2300 in a given day. While testing on my virtual server, it gives me a 500 error if my array includes variables for 0800 and 0900; when I remove them, the site loads fine. Am I missing something?

When I try it without the 0800 and 0900 lines, it runs fine. When I try it with just those two lines (or either one or the other) it refuses to load.

<?php

  $schedule = array(

      dotw        =>  "Thursday",
      0000        =>  "Good Night Owl (Books)",
      0100        =>  "After Midnight",
      0200        =>  "It Makes a Difference",
      0300        =>  "Special Interest Programs",
      0400        =>  "Chautauqua (Non Fiction Books)",
      0500        =>  "National Enquirer",
      0600        =>  "Sunday New York Times (Travel)",
      0700        =>  "Environmental Magazines",
      0800        =>  "Kansas Newspapers",
      0900        =>  "San Antonio Express-News",
      1000        =>  "San Antonio Express-News",
      1100        =>  "San Antonio Grocery Ads/Foods/Recipes",
      1200        =>  "USA Today",
      1300        =>  "Famous and Infamous",
      1400        =>  "Book Potpourri",
      1500        =>  "Smithsonian",
      1600        =>  "Acclaimed Books",
      1700        =>  "Commentary",
      1800        =>  "New York Times",
      1900        =>  "San Antonio Express-News",
      2000        =>  "San Antonio Express-News",
      2100        =>  "San Antonio Grocery Ads",
      2200        =>  "USA Today",
      2300        =>  "Evening Odyssey"
  );

?>
  • See [this](https://stackoverflow.com/a/10696097/7644018) ... the leading zeroes are not used as expected, so you may need strings for those. – Paul T. Jun 15 '19 at 04:23

1 Answers1

0

You're using integers as keys to your array. Integers beginning with a leading zero (as in 0700) are treated as octal numbers (i.e. base 8), and digits 8 and 9 are not valid in octal numbers, hence the error.

One solution might be to use strings inserted of integers:

"0800" => "Kansas Newspapers",

Be consistent: use strings throughout if you go this route.

Alternatively, just drop the leading zeros

800 => 'Kansas Newspapers',

This approach might require additional formatting for output.