3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array( 0 => array ( 'Id' => '1', 'Departments' => 'Account Management', 'Parent Id' => 0 ), 1 => array ( 'Id' => 2, 'Departments' => 'Ad Operations', 'Parent Id' => 0 ), 2 => array ( 'Id' => 3, 'Departments' => 'Corporate', 'Parent Id' => 0 ), 3 => array ( 'Id' => 4, 'Departments' => 'Creative Solutions', 'Parent Id' => 0 ), 4 => array ( 'Id' => 5, 'Departments' => 'Data & Research', 'Parent Id' => 0 ), 5 => array ( 'Id' => 6, 'Departments' => 'ENS - Account Management', 'Parent Id' => 0 ), 6 => array ( 'Id' => 7, 'Departments' => 'ENS - Creative Solutions', 'Parent Id' => 0 ), 7 => array ( 'Id' => 8, 'Departments' => 'ENS - Development', 'Parent Id' => 0 ), 8 => array ( 'Id' => 9, 'Departments' => 'ENS - Engineering', 'Parent Id' => 0 ), 9 => array ( 'Id' => 10, 'Departments' => 'ENS - Management', 'Parent Id' => 0 ), 10 => array ( 'Id' => 11, 'Departments' => 'ENS - Product Management', 'Parent Id' => 0 ), 11 => array ( 'Id' => 12, 'Departments' => 'Exchange', 'Parent Id' => 0 ), 12 => array ( 'Id' => 13, 'Departments' => 'Finance', 'Parent Id' => 0 ), 13 => array ( 'Id' => 14, 'Departments' => 'Human Resources', 'Parent Id' => 0 ), 14 => array ( 'Id' => 15, 'Departments' => 'Inventory', 'Parent Id' => 0 ), 15 => array ( 'Id' => 16, 'Departments' => 'Management', 'Parent Id' => 0 ), 16 => array ( 'Id' => 17, 'Departments' => 'Marketing', 'Parent Id' => 0 ), 17 => array ( 'Id' => 18, 'Departments' => 'Operations', 'Parent Id' => 0 ), 18 => array ( 'Id' => 19, 'Departments' => 'Product Strategy', 'Parent Id' => 0 ), 19 => array ( 'Id' => 20, 'Departments' => 'R&D', 'Parent Id' => 0 ), 20 => array ( 'Id' => 21, 'Departments' => 'Sales ', 'Parent Id' => 0 ), 21 => array ( 'Id' => 22, 'Departments' => 'Tech Sol - Client Services', 'Parent Id' => 0 ), 22 => array ( 'Id' => 23, 'Departments' => 'Tech Sol - Management', 'Parent Id' => 0 ), 23 => array ( 'Id' => 24, 'Departments' => 'Technology Sales', 'Parent Id' => 0 ), 24 => array ( 'Id' => 25, 'Departments' => 'UK - Account Management', 'Parent Id' => 0 ), 25 => array ( 'Id' => 26, 'Departments' => 'UK - Ad Ops', 'Parent Id' => 0 ), 26 => array ( 'Id' => 27, 'Departments' => 'UK - Creative', 'Parent Id' => 0 ), 27 => array ( 'Id' => 28, 'Departments' => 'UK - Finance', 'Parent Id' => 0 ), 28 => array ( 'Id' => 29, 'Departments' => 'UK - Inventory', 'Parent Id' => 0 ), 29 => array ( 'Id' => 30, 'Departments' => 'UK - Management', 'Parent Id' => 0 ), 30 => array ( 'Id' => 31, 'Departments' => 'UK - Sales', 'Parent Id' => 0 ), 31 => array ( 'Id' => 32, 'Departments' => 'UK - Sales Management', 'Parent Id' => 0 ), 32 => array ( 'Id' => 33, 'Departments' => 'R&D - Data Sciences', 'Parent Id' => 20 ), 33 => array ( 'Id' => 34, 'Departments' => 'R&D - Data/Tech Ops', 'Parent Id' => 20 ), 34 => array ( 'Id' => 35, 'Departments' => 'R&D - Development', 'Parent Id' => 20 ), 35 => array ( 'Id' => 36, 'Departments' => 'R&D - Engineering', 'Parent Id' => 20 ), 36 => array ( 'Id' => 37, 'Departments' => 'R&D - Management', 'Parent Id' => 20 ), 37 => array ( 'Id' => 38, 'Departments' => 'R&D - Product Management', 'Parent Id' => 20 ), 38 => array ( 'Id' => 39, 'Departments' => 'R&D - Data Sciences', 'Parent Id' => 20 ), 39 => array ( 'Id' => 40, 'Departments' => 'Sales  - Advertising Solutions Group', 'Parent Id' => 21 ), 40 => array ( 'Id' => 41, 'Departments' => 'Sales - Creative Solutions', 'Parent Id' => 21 ), 41 => array ( 'Id' => 42, 'Departments' => 'Sales - Emerging Media', 'Parent Id' => 21 ), 42 => array ( 'Id' => 43, 'Departments' => 'Sales - Exchange', 'Parent Id' => 21 ), 43 => array ( 'Id' => 44, 'Departments' => 'Sales - Management', 'Parent Id' => 21 ), 44 => array ( 'Id' => 45, 'Departments' => 'Sales - Media', 'Parent Id' => 21 ), 45 => array ( 'Id' => 46, 'Departments' => 'Legal', 'Parent Id' => 0 ) ); var_dump($a);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(46) { [0]=> array(3) { ["Id"]=> string(1) "1" ["Departments"]=> string(18) "Account Management" ["Parent Id"]=> int(0) } [1]=> array(3) { ["Id"]=> int(2) ["Departments"]=> string(13) "Ad Operations" ["Parent Id"]=> int(0) } [2]=> array(3) { ["Id"]=> int(3) ["Departments"]=> string(9) "Corporate" ["Parent Id"]=> int(0) } [3]=> array(3) { ["Id"]=> int(4) ["Departments"]=> string(18) "Creative Solutions" ["Parent Id"]=> int(0) } [4]=> array(3) { ["Id"]=> int(5) ["Departments"]=> string(15) "Data & Research" ["Parent Id"]=> int(0) } [5]=> array(3) { ["Id"]=> int(6) ["Departments"]=> string(24) "ENS - Account Management" ["Parent Id"]=> int(0) } [6]=> array(3) { ["Id"]=> int(7) ["Departments"]=> string(24) "ENS - Creative Solutions" ["Parent Id"]=> int(0) } [7]=> array(3) { ["Id"]=> int(8) ["Departments"]=> string(17) "ENS - Development" ["Parent Id"]=> int(0) } [8]=> array(3) { ["Id"]=> int(9) ["Departments"]=> string(17) "ENS - Engineering" ["Parent Id"]=> int(0) } [9]=> array(3) { ["Id"]=> int(10) ["Departments"]=> string(16) "ENS - Management" ["Parent Id"]=> int(0) } [10]=> array(3) { ["Id"]=> int(11) ["Departments"]=> string(24) "ENS - Product Management" ["Parent Id"]=> int(0) } [11]=> array(3) { ["Id"]=> int(12) ["Departments"]=> string(8) "Exchange" ["Parent Id"]=> int(0) } [12]=> array(3) { ["Id"]=> int(13) ["Departments"]=> string(7) "Finance" ["Parent Id"]=> int(0) } [13]=> array(3) { ["Id"]=> int(14) ["Departments"]=> string(15) "Human Resources" ["Parent Id"]=> int(0) } [14]=> array(3) { ["Id"]=> int(15) ["Departments"]=> string(9) "Inventory" ["Parent Id"]=> int(0) } [15]=> array(3) { ["Id"]=> int(16) ["Departments"]=> string(10) "Management" ["Parent Id"]=> int(0) } [16]=> array(3) { ["Id"]=> int(17) ["Departments"]=> string(9) "Marketing" ["Parent Id"]=> int(0) } [17]=> array(3) { ["Id"]=> int(18) ["Departments"]=> string(10) "Operations" ["Parent Id"]=> int(0) } [18]=> array(3) { ["Id"]=> int(19) ["Departments"]=> string(16) "Product Strategy" ["Parent Id"]=> int(0) } [19]=> array(3) { ["Id"]=> int(20) ["Departments"]=> string(3) "R&D" ["Parent Id"]=> int(0) } [20]=> array(3) { ["Id"]=> int(21) ["Departments"]=> string(7) "Sales " ["Parent Id"]=> int(0) } [21]=> array(3) { ["Id"]=> int(22) ["Departments"]=> string(26) "Tech Sol - Client Services" ["Parent Id"]=> int(0) } [22]=> array(3) { ["Id"]=> int(23) ["Departments"]=> string(21) "Tech Sol - Management" ["Parent Id"]=> int(0) } [23]=> array(3) { ["Id"]=> int(24) ["Departments"]=> string(16) "Technology Sales" ["Parent Id"]=> int(0) } [24]=> array(3) { ["Id"]=> int(25) ["Departments"]=> string(23) "UK - Account Management" ["Parent Id"]=> int(0) } [25]=> array(3) { ["Id"]=> int(26) ["Departments"]=> string(11) "UK - Ad Ops" ["Parent Id"]=> int(0) } [26]=> array(3) { ["Id"]=> int(27) ["Departments"]=> string(13) "UK - Creative" ["Parent Id"]=> int(0) } [27]=> array(3) { ["Id"]=> int(28) ["Departments"]=> string(12) "UK - Finance" ["Parent Id"]=> int(0) } [28]=> array(3) { ["Id"]=> int(29) ["Departments"]=> string(14) "UK - Inventory" ["Parent Id"]=> int(0) } [29]=> array(3) { ["Id"]=> int(30) ["Departments"]=> string(15) "UK - Management" ["Parent Id"]=> int(0) } [30]=> array(3) { ["Id"]=> int(31) ["Departments"]=> string(10) "UK - Sales" ["Parent Id"]=> int(0) } [31]=> array(3) { ["Id"]=> int(32) ["Departments"]=> string(21) "UK - Sales Management" ["Parent Id"]=> int(0) } [32]=> array(3) { ["Id"]=> int(33) ["Departments"]=> string(19) "R&D - Data Sciences" ["Parent Id"]=> int(20) } [33]=> array(3) { ["Id"]=> int(34) ["Departments"]=> string(19) "R&D - Data/Tech Ops" ["Parent Id"]=> int(20) } [34]=> array(3) { ["Id"]=> int(35) ["Departments"]=> string(17) "R&D - Development" ["Parent Id"]=> int(20) } [35]=> array(3) { ["Id"]=> int(36) ["Departments"]=> string(17) "R&D - Engineering" ["Parent Id"]=> int(20) } [36]=> array(3) { ["Id"]=> int(37) ["Departments"]=> string(16) "R&D - Management" ["Parent Id"]=> int(20) } [37]=> array(3) { ["Id"]=> int(38) ["Departments"]=> string(24) "R&D - Product Management" ["Parent Id"]=> int(20) } [38]=> array(3) { ["Id"]=> int(39) ["Departments"]=> string(19) "R&D - Data Sciences" ["Parent Id"]=> int(20) } [39]=> array(3) { ["Id"]=> int(40) ["Departments"]=> string(37) "Sales  - Advertising Solutions Group" ["Parent Id"]=> int(21) } [40]=> array(3) { ["Id"]=> int(41) ["Departments"]=> string(27) "Sales - Creative Solutions" ["Parent Id"]=> int(21) } [41]=> array(3) { ["Id"]=> int(42) ["Departments"]=> string(23) "Sales - Emerging Media" ["Parent Id"]=> int(21) } [42]=> array(3) { ["Id"]=> int(43) ["Departments"]=> string(17) "Sales - Exchange" ["Parent Id"]=> int(21) } [43]=> array(3) { ["Id"]=> int(44) ["Departments"]=> string(19) "Sales - Management" ["Parent Id"]=> int(21) } [44]=> array(3) { ["Id"]=> int(45) ["Departments"]=> string(14) "Sales - Media" ["Parent Id"]=> int(21) } [45]=> array(3) { ["Id"]=> int(46) ["Departments"]=> string(5) "Legal" ["Parent Id"]=> int(0) } }