3v4l.org

run code in 300+ PHP versions simultaneously
<?php $product = [ 'title' => 'Modest Swimsuit - Full body', 'description' => 'UV +50 Protection - Chlorine Resistant - Water Resistant - Quick Drying - Maximum Breathe Ability- Sea, Water Resistant', 'price' => 59.95, 'stock' => 20, ]; $attributes = [ ['name' => 'Brand', 'value' => 'Modestly Active Swimwear'], ['name' => 'Colour', 'value' => 'Black and Light Blue'], ['name' => 'size', 'value' => 'small'], ['name' => 'size', 'value' => 'medium'], ['name' => 'size', 'value' => 'large'], ]; $pivoted = []; foreach ($attributes as ['name' => $name, 'value' => $value]) { $name = strtolower($name); if (isset($pivoted[$name])) { $pivoted[$name] = (array) $pivoted[$name]; $pivoted[$name][] = $value; } else { $pivoted[$name] = $value; } } var_export($product + $pivoted);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'title' => 'Modest Swimsuit - Full body', 'description' => 'UV +50 Protection - Chlorine Resistant - Water Resistant - Quick Drying - Maximum Breathe Ability- Sea, Water Resistant', 'price' => 59.95, 'stock' => 20, 'brand' => 'Modestly Active Swimwear', 'colour' => 'Black and Light Blue', 'size' => array ( 0 => 'small', 1 => 'medium', 2 => 'large', ), )

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:
80.72 ms | 406 KiB | 5 Q