Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6747913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:30:09+00:00 2026-05-26T12:30:09+00:00

I have a PHP single dimension array, when using the json_encode function on that

  • 0

I have a PHP single dimension array, when using the json_encode function on that array I get a json object returned but it has a leading 0 before the opening curly brace {.

0{"a1000":"b1000","a1200":"b1200"}

The PHP array is:

Array
(
    [a1000] => b1000
    [a1200] => b1200
)

On the same page, with a different (but same structured) request, the json object that is returned does not have a leading 0.

The error in the Chrome console is:

Uncaught SyntaxError: Unexpected token {

Has anyone ever come across this problem before?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:30:10+00:00Added an answer on May 26, 2026 at 12:30 pm

    Your PHP is likely outputting the 0 before the JSON. Although you didn’t show all you code, you should double check all of the following:

    • check there’s no text before your <?php tag
    • look for any rogue echo or print statements
    • check that you’re not using outputting functions such as readfile() or var_dump()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an single-dimensional array of PHP objects. Each object has two attributes, one
I have a PHP file using json_encode to make a single call, but it
I have a PHP program that has been written keeping in mind a single
Is that possible to have a single PHP SOAP server which will handle requests
Basically I have a single page on my site that I want any php
I realized that I can have problems with single quotes in php arrays: <?php
I've managed to make some single dimension array lists but I can't figure out
I have a single PHP file within a legacy project that is at least
Hey everyone... I'm not too familiar with PHP... but I have PHP code that
I am linking some stories on FaceBook, but the url I have is: http://webpage.com/single.php?2011/02/04/my-story-here.html

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.