{
"name" : "lv0",
"children" : [
{
"name" : "lv1",
"children" : [
{
"name" : "lv2",
"children" : [
{
"name" : "lv3"
}
]
}
]
}
]
}
this is the json and I only wants to count the number of children's array, I am using this code:
$data[] = $request->children;
$count = 0;
foreach($data as $data){
$count++;
}
return $count;