标签:php arch [1] res value 网络 color mes cti
<?php $data[0][‘spec_id‘] = 1; $data[0][‘type_id‘] = 1; $data[0][‘name‘] = ‘网络‘; $data[0][‘sort‘] = 50; $data[1][‘spec_id‘] = 1; $data[1][‘type_id‘] = 1; $data[1][‘name‘] = ‘内存‘; $data[1][‘sort‘] = 50; $data[2][‘spec_id‘] = 1; $data[2][‘type_id‘] = 1; $data[2][‘name‘] = ‘网络‘; $data[2][‘sort‘] = 50; $data[3][‘spec_id‘] = 1; $data[3][‘type_id‘] = 1; $data[3][‘name‘] = ‘屏幕‘; $data[3][‘sort‘] = 50; $data[4][‘spec_id‘] = 1; $data[4][‘type_id‘] = 1; $data[4][‘name‘] = ‘网络‘; $data[4][‘sort‘] = 50; $result = test($data); print_r($result);exit; function test($data) { // 健值数组 $names = array(); // 新数组 $info = array(); // 获取健值名 foreach($data as $value) { // 判断该名称是否已经添加 if (!in_array($value[‘name‘], $names)) { $names[] = $value[‘name‘]; $info[] = array(‘name‘ => $value[‘name‘], ‘list‘ => array()); } } foreach($data as $value) { // 获取名称对应的健值 $key = array_search($value[‘name‘], $names); $info[$key][‘list‘][] = $value; } return $info; } ?>
标签:php arch [1] res value 网络 color mes cti
原文地址:https://www.cnblogs.com/richerdyoung/p/10107426.html