我想通过定义一个键来创建一个基于另一个数组值的数组?通过定义一个键来基于另一个数组值创建一个数组?
E.g.
$old_array = array('hey', 'you', 'testing', 'this');
function get_new_array($key) {
global $old_array;
//return new array...
}
$new_array = get_new_array(2); //would return array('hey, 'you', 'testing'); as its the values of all the keys before the key 2 and the 2 key itself
感谢所有帮助! :B
如果你打算把它放在一个自定义的函数中,我觉得使用`global`是个好主意。 – BoltClock 2011-01-08 01:38:22