json - PHP json_decode() depth meaning

I'm saving some JSON and I don't know if this might later nib me in the butt if the JSON gets too big(The size depends on user input), though from my reading the max depth of 512 seems to be quite a high number and not really practical, but it triggered something in my mind and I've only now realized that I don't quite understand the meaning of "depth" of an array or how to count it (visually)...
I checked out this question while trying to get a clear understanding of depth: What is the purpose of using depth in JSON encode?
And the example given was:
array(
'foo',
'bar',
'baz'
)
// Has depth of 1
array(
array(
'foo'
),
array(
'bar'
),
array(
'baz'
)
)
// Has depth 2
But what about...
array(
array(
'foo'
),
array(
'bar'
),
array(
array(
'baz' => 'caz'
)
)
Or
array(
array(
'foo'
),
array(
'bar'
),
array(
array(
'baz' => 'caz'
),
array(
'tree' => array(
'tree-a' => array(
'car-a' => 'car-b'
)
)
)
)
I know this might be obvious to some but it's just one of those things I never thought much about. I did check out the documentation forjson_decode()
and it's depth parameter but still couldn't wrap my head around it. Maybe there's some rule of thumb i can use?
I'm trying to understand this in the context of when using json_decode();
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: sqlstate[23000]: integrity constraint violation: 1452 cannot add or update a child row: a foreign key constraint fails
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.