3v4l.org

run code in 300+ PHP versions simultaneously
<?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(array_filter($a, function($department){ var_dump($department['Departments']);return ($department['Departments'] == 'Sales - Creative Solutions'); })); $b = []; $b['Sales  - Advertising Solutions Group'] = 1; var_dump($b);
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
string(18) "Account Management" string(13) "Ad Operations" string(9) "Corporate" string(18) "Creative Solutions" string(15) "Data & Research" string(24) "ENS - Account Management" string(24) "ENS - Creative Solutions" string(17) "ENS - Development" string(17) "ENS - Engineering" string(16) "ENS - Management" string(24) "ENS - Product Management" string(8) "Exchange" string(7) "Finance" string(15) "Human Resources" string(9) "Inventory" string(10) "Management" string(9) "Marketing" string(10) "Operations" string(16) "Product Strategy" string(3) "R&D" string(7) "Sales " string(26) "Tech Sol - Client Services" string(21) "Tech Sol - Management" string(16) "Technology Sales" string(23) "UK - Account Management" string(11) "UK - Ad Ops" string(13) "UK - Creative" string(12) "UK - Finance" string(14) "UK - Inventory" string(15) "UK - Management" string(10) "UK - Sales" string(21) "UK - Sales Management" string(19) "R&D - Data Sciences" string(19) "R&D - Data/Tech Ops" string(17) "R&D - Development" string(17) "R&D - Engineering" string(16) "R&D - Management" string(24) "R&D - Product Management" string(19) "R&D - Data Sciences" string(37) "Sales  - Advertising Solutions Group" string(27) "Sales - Creative Solutions" string(23) "Sales - Emerging Media" string(17) "Sales - Exchange" string(19) "Sales - Management" string(14) "Sales - Media" string(5) "Legal" array(0) { } array(1) { ["Sales  - Advertising Solutions Group"]=> int(1) }
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/PNbF5 on line 329
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/PNbF5 on line 328
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/PNbF5 on line 328
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/PNbF5 on line 328
Process exited with code 255.

preferences:
260.63 ms | 401 KiB | 329 Q