3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(Array ( 0 => "ISP2", 1 => "ISP3", 2 => "ISP4" ), Array ( 0 => "NAME-A", 1 => "NAME-B", 2 => "NAME-C" ), Array ( 0 => "property1", 1 => "property2", 2 => "property2" )); $result = array(); Foreach($arr[2] as $key => $prop){ $result[$prop]["charges"][] =$arr[0][$key]; $result[$prop]["names"][] = $arr[1][$key]; } Var_dump($result);
Output for 7.0.0 - 7.0.25, 7.1.0 - 7.1.20, 7.2.5 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.15, 8.5.0 - 8.5.1
array(2) { ["property1"]=> array(2) { ["charges"]=> array(1) { [0]=> string(4) "ISP2" } ["names"]=> array(1) { [0]=> string(6) "NAME-A" } } ["property2"]=> array(2) { ["charges"]=> array(2) { [0]=> string(4) "ISP3" [1]=> string(4) "ISP4" } ["names"]=> array(2) { [0]=> string(6) "NAME-B" [1]=> string(6) "NAME-C" } } }

preferences:
185.61 ms | 409 KiB | 5 Q