Advertisement
Guest User

Untitled

a guest
Sep 7th, 2016
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. require __DIR__.'/vendor/autoload.php';
  4.  
  5. $a = [
  6.     [
  7.         "id" => 24, "child" => [
  8.             "id" => 29, "child" => [
  9.                 "id" => 50, "child" => [
  10.                     "id" => 82, "child" => []
  11.                 ]
  12.             ]
  13.         ]
  14.     ],
  15.     [ "id" => 30, "child" => [], ],
  16.     [ "id" => 31, "child" => [], ],
  17.     [ "id" => 32, "child" => [], ],
  18. ];
  19.  
  20. $childIds = collect($a)->map(function ($item) {
  21.     return collect($item)->flatten();
  22. });
  23.  
  24. dd($childIds->all());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement