0

img

How do I add digits per objects?

https://paste.ubuntu.com/p/mSzJnY87KF/

I want to do;

img

what I have to do, I have tried many ways.

tnks for responses

4
  • digits in second img are keys and are strings! Commented Feb 3, 2019 at 19:12
  • you can find your anser in stackoverflow.com/questions/19447175/… Commented Feb 3, 2019 at 19:13
  • the link you sent is not working for me :// Commented Feb 3, 2019 at 19:15
  • Edit: text instead of images please. Consecutive numeric keys will always be encoded as array. Unless $i starts at 1 / skips indexes / or simply is ordered is reverse, there won't be "1": object keys. Commented Feb 3, 2019 at 19:22

1 Answer 1

0

Just need some thing like this

$arr = [];
$arr["1"] = "content 1";
$arr["10"] = "content 2";
echo json_encode($arr);

do not use array_push

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.