3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ('1' => (object)array( 'id' => 225, 'user_id' => 1, 'name' => 'Blue Quilted Leather Jacket by Minusey - $499' ), '2' => (object)array( 'id' => 222, 'user_id' => 1, 'name' => 'Darling New Bathtub by Duravit - $6300' ), '3' => (object)array( 'id' => 222, 'user_id' => 1, 'name' => 'Darling New Bathtub by Duravit - $6300' ) ); //print_r(array_column((array)$array, 'id')); function array_unique_by_key($array, $key = 'id') { $found = array(); // Encountered IDs $out = array(); // Output array foreach ($array as $value) { if (!array_key_exists($key, $value)) throw new Exception('Can\'t find key "' . $key . '"'); $id = $value[$key]; // If already encountered, skip if (in_array($id, $found)) continue; // Otherwise, add to found values and to output array $found[] = $id; $out[] = $value; } return $out; } print_r(array_unique_by_key($array));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, stdClass given in /in/JI5OK:28 Stack trace: #0 /in/JI5OK(41): array_unique_by_key(Array) #1 {main} thrown in /in/JI5OK on line 28
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
34.61 ms | 401 KiB | 8 Q