Note that there are some explanatory texts on larger screens.

plurals
  1. POFind the depth of a root indexed array from a particular node
    primarykey
    data
    text
    <p>I have an array like</p> <pre><code> Array ( [0] =&gt; Array ( [id] =&gt; 81 [cata_key] =&gt; 908cbbcb86a1cf64b67c96ff [cata_name] =&gt; Lunch [app_key] =&gt; 2fabc0d9447c6375657dead4 [parentid] =&gt; 0 [subcategories] =&gt; Array ( ) ) [1] =&gt; Array ( [id] =&gt; 80 [cata_key] =&gt; baac98b4e73c05ebbf45bdc6 [cata_name] =&gt; Break Fast [app_key] =&gt; 2fabc0d9447c6375657dead4 [parentid] =&gt; 0 [subcategories] =&gt; Array ( [0] =&gt; Array ( [id] =&gt; 82 [cata_key] =&gt; 5970b7afc450ef3b24573de9 [cata_name] =&gt; Rise Products [app_key] =&gt; 2fabc0d9447c6375657dead4 [parentid] =&gt; 80 [subcategories] =&gt; Array ( [0] =&gt; Array ( [id] =&gt; 83 [cata_key] =&gt; 82e36d8f821e14fc8db1d4da [cata_name] =&gt; Dosha [app_key] =&gt; 2fabc0d9447c6375657dead4 [parentid] =&gt; 82 [subcategories] =&gt; Array ( [0] =&gt; Array ( [id] =&gt; 84 [cata_key] =&gt; 49730020d850439dd7de8747 [cata_name] =&gt; Masala Dosha [app_key] =&gt; 2fabc0d9447c6375657dead4 [parentid] =&gt; 83 [subcategories] =&gt; Array ( ) ) ) ) ) ) ) ) ) </code></pre> <p>I would like to find the depth of the root indexed sub array from a particular inner array id. For example I would like to find the depth of the root indexed array from the parentid=0, it should be 1. The depth of the root indexed sub array from the parentId=0/80/82/83 should be 4. </p> <p>Actually my aim is to limit the depth of an array. There should a depth limit. So when any one try to add a sub array to this array , we should find out the current array depth . For example the array depth limit is 4 , and any one try to add a sub array under cata_name= Masala Dosha, the depth already reached and should not allow to add new sub array. But at the same time he can add a sub array under [cata_name] => Lunch, because its depth is only 1 and the depth limit is 4. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload