3v4l.org

run code in 300+ PHP versions simultaneously
<?php $people = [ ['id' => 2, 'name' => 'John Smith', 'gender' => 'male'], ['id' => 35, 'name' => 'Gareth Foo', 'gender' => 'male'], ['id' => 91, 'name' => 'John Smith', 'gender' => 'male'], ['id' => 27, 'name' => 'Bobby Smith', 'gender' => null], ['id' => 44, 'name' => 'Jane Doe', 'gender' => 'female'], ]; $selectedIds = [44, 91]; $identifiedNames = array_column($people, 'name', 'id'); $filteredNames = array_intersect_key($identifiedNames, array_flip($selectedIds)); var_export($filteredNames);
Output for 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.4, 8.3.6
array ( 91 => 'John Smith', 44 => 'Jane Doe', )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array ( 91 => 'John Smith', 44 => 'Jane Doe', )

preferences:
171.2 ms | 402 KiB | 150 Q