您好,欢迎访问一九零五行业门户网

这个数组怎么拆?

array ( [0] => array ( [country] => 越南 [dausum] => 300 ) [1] => array ( [country] => 中国 [dausum] => 500 ) [2] => array ( [country] => 香港 [dausum] => 600 ) )

这个大数组拆成
$country=('越南','中国','香港'); $data=('越南'=>'300','中国'=>300,'香港'=>'600);

回复内容: array ( [0] => array ( [country] => 越南 [dausum] => 300 ) [1] => array ( [country] => 中国 [dausum] => 500 ) [2] => array ( [country] => 香港 [dausum] => 600 ) )

这个大数组拆成
$country=('越南','中国','香港'); $data=('越南'=>'300','中国'=>300,'香港'=>'600);

$arr = [ ['country' => '越南', 'dausum' => 300], ['country' => '中国', 'dausum' => 500], ['country' => '香港', 'dausum' => 600]];$country = $data = array();foreach($arr as $elem){ $country[] = $elem['country']; $data[$elem['country']] = $elem['dausum'];}
$arr = [ ['country' => '越南', 'dausum' => 300], ['country' => '中国', 'dausum' => 500], ['country' => '香港', 'dausum' => 600]];$country = array_column($arr, 'country');$data = array_combine($country, array_column($arr, 'dausum'));
其它类似信息

推荐信息