数组
<?php
//$str='high-school-student-informantion-management-system';
// $arr= explode('-',$str);
//var_dump($arr);
//
$student = [
['name' => '张三', 'c_id' => 1],
['name' => '李四', 'c_id' => 1],
['name' => '王五', 'c_id' => 1],
['name' => '赵六', 'c_id' => 2],
['name' => '田七', 'c_id' => 2],
['name' => '周八', 'c_id' => 2],
['name' => '张三', 'c_id' => 2],
];
$class = [
'1' => '1905a',
'2' => '1906a'
];
//$result=[];
//foreach ($student as $k=>$v){
//$cid=$v['c_id'];
//$classname=$class[$cid];
////print_r($classname);
// $result[$classname][]=$v['name'];
//
//}
//print_r($result);
$json='{"type_name":"电脑","spec":[{"name":"颜色","value":["红色","黑色","蓝色"]},
{"name":"内存","value":["64G","256G"]}],"attr":[{"name":"毛重","value":"10g"},
{"name":"产地","value":"北京"}]}';
$new_json=json_decode($json,true);
$arr=[];
foreach ($new_json['spec'][0]['value'] as $k =>$v){
$arr[$k]['type_name']=$new_json['type_name'];
$arr[$k]['color']=$v;
};
print_r($arr);