3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rawArray = array("A"=>"['B' => 3, 'C' => 5, 'D' => 9],", "B"=>"['A' => 3, 'C' => 3, 'D' => 4, 'E' => 7],", "C"=>"['A' => 5, 'B' => 3, 'D' => 2, 'E' => 6, 'F' => 3],", "D"=>"['A' => 9, 'B' => 4, 'C' => 2, 'E' => 2, 'F' => 2],", "E"=>"['B' => 7, 'C' => 6, 'D' => 2, 'F' => 5],", "F"=>"['C' => 3, 'D' => 2, 'E' => 5],", ); foreach($rawArray as $k => $v){ preg_match_all("/\'(.)\'/", $v, $key); preg_match_all("/=> (\d)/", $v, $val); $graph[$k] = array_combine($key[1], $val[1]); } print_r($graph);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Array ( [A] => Array ( [B] => 3 [C] => 5 [D] => 9 ) [B] => Array ( [A] => 3 [C] => 3 [D] => 4 [E] => 7 ) [C] => Array ( [A] => 5 [B] => 3 [D] => 2 [E] => 6 [F] => 3 ) [D] => Array ( [A] => 9 [B] => 4 [C] => 2 [E] => 2 [F] => 2 ) [E] => Array ( [B] => 7 [C] => 6 [D] => 2 [F] => 5 ) [F] => Array ( [C] => 3 [D] => 2 [E] => 5 ) )

preferences:
81.52 ms | 409 KiB | 5 Q