我正在寻找一种拦截动作的方法array_push
,因为当它被检索时,数组的每个值都有另一个信息,例如:
class ClassName {
var $test = array();
function __set($attr, $value) {
$this->$attr = 'My extra value'.$value;
}
function index(){
array_push($this->test, "some val");
array_push($this->test, "some other val");
print_r($this->test);
}
}
$o = new ClassName();
$o->index();
并期望得到类似的东西:
Array
(
[0] => My extra value some val
[1] => My extra value some other val
)
但我得到:
Array
(
[0] => some val
[1] => some other val
)
谢谢大家