Apart from creating a mapper object, there isn't much you can do. For example:
class customMapper {
private $customMap = NULL;
public function __construct($customMap){
$this->customMap = $customMap;
}
public function map($data){
return $data[$this->customMap];
}
}
And then inside your function, instead of creating your own mapper, use the new class:
$ids = array_map(array(new customMapper('param2'), 'map'), $data['student_teacher']);
This will allow you to create a custom mapper that can return any kind of information... And you can complexify your customMapper to accept more fields or configuration easily.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…