Convert or push object in array?

{
"226": {
"id": "226",
"cmd": "C1111",
"log": [
{
"id": Standard",
"name": "Poste",
},
{
"id": Basic",
"name": "Poste 2",
}
]
}
}

Welcome to the forums @lamjedjarray

It’s not at all clear what you are asking here.
Can you clarify exactly what your question is?

Welcome to the forums, @lamjedjarray. Your question is not very clear. Could you please explain or provide more information about what you are trying to do?

i want to push object into array using php and find any object by id .
you are reading the code on the bottom ( is an example to push and get )


{
"226": {
"id": "226",
"cmd": "C1111",
"log": [
{
"id": Standard",
"name": "Poste",
},
{
"id": Basic",
"name": "Poste 2",
}
]
}
}

thank you very much

It does look a bit confusing. There are two “id” properties, a numeric String, and two improperly quoted text Strings.

I’m assuming you want to push to the “log” array(s).

Have you managed to be able to var dump “log” and the value looks OK?

use json_decode(), array_push() and json_encode()

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.