3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ "sku" => [ 0 => "dSADad", 1 => "ASDAF", 2 => "ASFAS", // ... ], "Price" => [ 0 => "1", 1 => "1", 2 => "1", // ... ], "Quantity" => [ 0 => "123", 1 => "123", 2 => "123434", // ... ], "attributes" => [ "Color" => [ 0 => "5", 1 => "4", 2 => "4", // ... ], "Size" => [ 0 => "3", 1 => "3", 2 => "2", // ... ], "Material" => [ 0 => "7", 1 => "7", 2 => "8", // ... ], ], ]; $result = []; foreach ($array as $k1 => $v1) { foreach ($v1 as $k2 => $v2) { if (is_array($v2)) { foreach ($v2 as $k3 => $v3) { $result[$k3][$k1][$k2] = $v3; } } else { $result[$k2][$k1] = $v2; } } } var_export($result);
Output for rfc.property-hooks, git.master, git.master_jit
array ( 0 => array ( 'sku' => 'dSADad', 'Price' => '1', 'Quantity' => '123', 'attributes' => array ( 'Color' => '5', 'Size' => '3', 'Material' => '7', ), ), 1 => array ( 'sku' => 'ASDAF', 'Price' => '1', 'Quantity' => '123', 'attributes' => array ( 'Color' => '4', 'Size' => '3', 'Material' => '7', ), ), 2 => array ( 'sku' => 'ASFAS', 'Price' => '1', 'Quantity' => '123434', 'attributes' => array ( 'Color' => '4', 'Size' => '2', 'Material' => '8', ), ), )

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:
57.42 ms | 1206 KiB | 4 Q