...
|
...
|
@@ -108,11 +108,51 @@ class ClassModel |
|
|
foreach ($classesData as $val) {
|
|
|
foreach ($val['ca'] as $single) {
|
|
|
$classes[$single['id']] = $single['name'];
|
|
|
$classes += array_column($single['sub'], 'name', 'id');
|
|
|
$classes += self::array_column($single['sub'], 'name', 'id');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $classes;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 自定义array_column函数
|
|
|
*
|
|
|
* @return array 返回数组中指定的一列组成的数组
|
|
|
*/
|
|
|
/**
|
|
|
* 自定义array_column函数
|
|
|
* @param array $input 需要取出数组咧的多维数组
|
|
|
* @param string $columnKey 需要返回的列
|
|
|
* @param mixed $indexKey 作为返回数组的索引值
|
|
|
* @return array 从多维数组中返回单列数组
|
|
|
*/
|
|
|
private static function array_column(array $input, $columnKey, $indexKey = null)
|
|
|
{
|
|
|
$array = array();
|
|
|
foreach ($input as $value) {
|
|
|
if ( ! isset($value[$columnKey])) {
|
|
|
trigger_error("Key \"$columnKey\" does not exist in array");
|
|
|
return false;
|
|
|
}
|
|
|
if (is_null($indexKey)) {
|
|
|
$array[] = $value[$columnKey];
|
|
|
}
|
|
|
else {
|
|
|
if ( ! isset($value[$indexKey])) {
|
|
|
trigger_error("Key \"$indexKey\" does not exist in array");
|
|
|
return false;
|
|
|
}
|
|
|
if ( ! is_scalar($value[$indexKey])) {
|
|
|
trigger_error("Key \"$indexKey\" does not contain scalar value");
|
|
|
return false;
|
|
|
}
|
|
|
$array[$value[$indexKey]] = $value[$columnKey];
|
|
|
}
|
|
|
}
|
|
|
return $array;
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|