$allnodes=[
0 =>["userid" => 10012,"lft" => 4,"rgt" => 5,"rank" => 1],
1 =>["userid" => 10006,"lft" => 6,"rgt" => 7,"rank" => 2],
2 =>["userid" => 10011,"lft" => 14,"rgt" => 15,"rank" => 3],
3 =>["userid" => 10008,"lft" => 16,"rgt" => 19,"rank" => 1],
4 =>["userid" => 10013,"lft" => 22,"rgt" => 23,"rank" => 1]
];
how to find the result set corresponding to lft+rgt < = 27. The correct result should be line 0pl.
is there any efficient algorithm? I remember that in c-sharp, it seems that you can turn this form into a virtual table, and you can use SQL statements. Check directly in memory without linking to the database. Does it seem that it can only be ergodic in php?
foreach should be able to calculate quickly, traversing line by line. Is there a built-in php array function that can be worked out without a loop?