3v4l.org

run code in 300+ PHP versions simultaneously
<?php $demo = [ (object) ['key' => 'a', 'xxx' => 'xxx'], (object) ['key' => 'b', 'xxx' => 'xxx'], (object) ['key' => 'c', 'xxx' => 'xxx'] ]; $result = array_combine(array_column($demo, 'key'), $demo); print_r($result);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Array ( [a] => stdClass Object ( [key] => a [xxx] => xxx ) [b] => stdClass Object ( [key] => b [xxx] => xxx ) [c] => stdClass Object ( [key] => c [xxx] => xxx ) )

preferences:
79.84 ms | 1303 KiB | 4 Q