1

I want to create MD array from numbers like below to send as JSON

OrderStatus  Counts
Shipped      3

Pending      5

Final output should be,

[{order_status: "Shipped", Counts: 3}, {order_status: "Pending", Counts: 5} ]

Currently i am able to send only 1 row with this,

$orderTable[] = array(
                'order_status' => 'Shipped',
                'Counts' => 3);

How can i send two values as Json array?

1 Answer 1

3

You can create your array like this:

$orderTable = [ 
   [
      'order_status' => 'Shipped',
      'Counts' => 3
   ],
   [
      'order_status' => 'Pending',
      'Counts' => 5
   ]
];

$json = json_encode($orderTable);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.