3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data[] = new stdClass; $data[0]->product_name = '1'; $data[0]->random_value = 'first'; $data[1]->product_name = '2'; $data[1]->random_value = 'second'; $data[2]->product_name = '2'; $data[2]->random_value = 'third'; $data[3]->product_name = '1'; $data[3]->random_value = 'fourth'; $data[4]->product_name = '3'; $data[4]->random_value = 'fifth'; $products = array(); foreach ($data as $data_object) { $products[$data_object->product_name][] = $data_object; } // product names are keys of $products var_dump(array_keys($products)); // products for each key var_dump($products);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Attempt to assign property "product_name" on null in /in/7ejmW:7 Stack trace: #0 {main} thrown in /in/7ejmW on line 7
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:
29.25 ms | 405 KiB | 5 Q