php find the next largest key in an array
php find the next greatest key in an array
There is undoubtedly a better way, but recursion has melted my brain and search engines aren't saving me.
So this is what I did... actually, I used another approach entirely that didn't need this. But array_keys
is how I would have started, then sorted it, and then had a foreach that compared my key to the keys it got as it walked through, and broken out of there with the new key the first one that was larger.
php find the next largest key in an array
php find the next greatest key in an array
There is undoubtedly a better way, but recursion has melted my brain and search engines aren't saving me.
So this is what I did... actually, I used another approach entirely that didn't need this. But array_keys
is how I would have started, then sorted it, and then had a foreach that compared my key to the keys it got as it walked through, and broken out of there with the new key the first one that was larger.
$terms_on_this_level = array_keys($parents);
I know there would have been a better way, but it's moot to me know anyway... until I search for this answer again and find my own, deeply unfulfilling, page.