Skip to content
Drempd Logo
  • home
  • portfolio
  • web design journal
  • blog
    • adventure
    • san diego
    • projects
    • website design
    • code notes
  • contact
Blog Web Dev PHP JSON Returned As Object Instead of Array

PHP JSON Returned As Object Instead of Array

By Forrest Smith - Drempd.com

I was returning, what I thought was an array from PHP, but it kept returning it as a json object, so I had something like:

$listItem[0][0] = “Jan 1”;
$listItem[0][1] = 100;

$listItem[1][0] = “Jan 2”;
$listItem[1][1] = 120;

$listItem[2][0] = “Jan 2”;
$listItem[2][1] = 120;

…etc…

This would return in javascript those an array, but the index for each set was actually an object.  What was going on was apparently my ordered sequence (0,1,2,…) was actually missing a number in there somehow, and that was turning it into an object instead of an array.  Apparently the array values need to start with 0 and can’t skip any numbers for it to be returned as a numerical array.

Posted on May 14, 2016August 26, 2022 in Web Dev

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I love to create and explore. Whether building a website or app, taking a long walk through the mountains, or playing with a random idea, I've found that there will never be enough time to experience it all. But that won't stop me from trying.

Web Design & Development

  • Portfolio
  • San Diego Website Design
  • Custom Web Design
  • Responsive Web Design
  • Website Maintenance
  • Freelance Web Designer
  • Web Design Posts
  • Website Checklist

Projects

  • Zindash
  • Opti
  • Saphire CSS
  • Ergo Blocks

Blog

  • Adventure
  • San Diego
  • Projects
  • Website Design
  • Technology
  • Code Notes

About

  • Bluesky
  • Resume
  • Contact
drempd | san diego, ca
© 2026 Drempd All rights reserved.