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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:14:17+00:00 2026-06-13T12:14:17+00:00

I am trying to pass a JSON string to my PHP script, but I

  • 0

I am trying to pass a JSON string to my PHP script, but I am unsure of how to build the string in a way that considers there could be 0 or more telephones, emails and faxes.

Here is an example of what my string looks like:

{"mode": "ADD_CONTACT", "id": 316, "firstname": "", "lastname": "", "telephones": {"teltype": 1, "telnumber": "234523453245", "isprimary": 0, "teltype": 4, "telnumber": "657567567567", "isprimary": 0}}

The problem is that my script only gives me the last phone number, presumably because the JSON parameter names are the same, so what format should I use to achieve what I want? I would like to avoid sticking incremental numbers on the end of the parameter names i.e. “telnumber1”, “telnumber2” etc.

  • 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-06-13T12:14:18+00:00Added an answer on June 13, 2026 at 12:14 pm

    Use an array (which can be empty):

    {..., "telephones": [{"teltype": 1, "telnumber": "234523453245", ...}, {...}]}
    

    Example:

    $json = 
      '{"telephones": [' .
        '{"teltype": 1, "telnumber": "222222222222"}, ' .
        '{"teltype": 1, "telnumber": "111111111111"}' .
      ']}';
    print_r(json_decode($json, true));
    
    Array
    (
        [telephones] => Array
            (
                [0] => Array
                    (
                        [teltype] => 1
                        [telnumber] => 222222222222
                    )
                [1] => Array
                    (
                        [teltype] => 1
                        [telnumber] => 111111111111
                    )
            )
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass multiple checkboxes with different values to a PHP script that
I am currently trying to pass a generated JSON string to dojo for parsing
I'm trying to pass an Int value pulled from a JSON String to reduce
I am trying to build a robust, simple, safe, catch-all way to pass dynamic
I'm trying to understand how my PHP script can pass an array to my
I am trying to pass a variable with a json string from C# to
I am trying to pass a jquery string to my cakephp controller but I
i am trying to pass non numeric index values through JSON but am not
While trying to pass part of a Json string to a function I get
I am trying to pass a JSON object to .getJSON but I keep getting

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.