慕容森
您可以使用以下示例合并您的数组<?php$mainArray = array(array('id' => 1, 'id_name' => 'a', 'id_vales' => 5), array('id' => 1,'id_name' => 'a','id_vales' => 4), array('id' => 3, 'id_name' => 'b','id_vales' => 4), array('id' => 3,'id_name' => 'b','id_vales' => 3));$result = array();$tempArray = array();foreach($mainArray as $key => $value){ if(isset($tempArray[$value['id']])) { $tempArray[$value['id']] .= ", ".$value['id_vales']; $result[] = array('id' => $value['id'], 'id_name' => $value['id_name'], 'id_vales' => $tempArray[$value['id']]); } else { $tempArray[$value['id']] = "".$value['id_vales']; }}echo "<pre>";print_r($result);?>您可以在此处找到运行示例https://paiza.io/projects/3sS3GXH7GHqoipH8k-YtBQ输出:Array( [0] => Array ( [id] => 1 [id_name] => a [id_vales] => 5, 4 ) [1] => Array ( [id] => 3 [id_name] => b [id_vales] => 4, 3 ))