<?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);
preferences:
24.06 ms | 406 KiB | 5 Q