1.子类访问父类静态方法
<?php class A{ static function loadById(){ $class_name = get_called_class(); $model = new $class_name('a'); return $model; } } class B extends A{ public $name; public function __construct($str){ $this->name = $str; } } echo "beginnn<Br>"; $obj = B::loadById(); echo $obj->name; ?>
$list{id=1,name='jiang',age=10}
print_r(arrayChangeKey($list, 'id'));
arrayChangeKey()函数array[id]={name,age}
function arrayChangeKey($arr,$key) {/*{{{*/ $processedArr = array(); if(is_array($arr) && !empty($arr)){ foreach ($arr as $item) { $processedArr[$item[$key]] = $item; } } return $processedArr; }