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 6754377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:16:21+00:00 2026-05-26T13:16:21+00:00

Possible Duplicate: json_encode is returning NULL? I’m having a strange problem with json_encode() in

  • 0

Possible Duplicate:
json_encode is returning NULL?

I’m having a strange problem with json_encode() in php. Pretty simple code:

$content = json_encode(array('content1' => $arm_length,
                             'content2' => $body_length));
echo $content;

$arm_length and $body_length variables contain the HTML markup for two select dropdown menus. My problem is when it echo‘s out it show’s NULL for content1 and content2. If I take the json_encode() away and just do print_r($content) it shows all the data as it should be.

Does anyone know what’s happening here? Is there certain data that can’t be parsed into JSON? I’ve done this a few times now using Ajax/PHP and never had any problems.

Cheers for any help with this.

  • 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-26T13:16:21+00:00Added an answer on May 26, 2026 at 1:16 pm

    json_encode() has the (undocumented) habit of silently nulling properties that contain invalid (= non-UTF-8) characters.

    Make sure your input data is UTF-8 encoded, which is a documented requirement of that function.

    In the event of a failure to encode, json_last_error() can be used to determine the exact nature of the error. (Available in PHP 5.3 only)

    Related: How to keep json_encode() from dropping strings with invalid characters

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP Sort a multidimensional array by element containing date I have some
Possible Duplicate: PHP Arrays: A good way to check if an array is associative
Possible Duplicate: PHP : Create array for JSON I have an array like this
Possible Duplicate: JSON Array iteration in Android/Java I am fetching JSON string from server
Possible Duplicate: How to copy part of an array to another array in C#
Possible Duplicate: or is not valid C++ : why does this code compile ?
Possible Duplicate: How to format a JSON date? My webs service is returning a
Possible Duplicate: JavaScript data formatting/pretty printer I am getting a bit tired of looking
Possible Duplicate: Can't decode JSON string in php I'm at my wits end here,
Possible Duplicate: Difference Between $.getJSON() and $.ajax() in jQuery super simple question.... between .getjson

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.