在python中我会这样做:
var = ["test","test1","test2","test3"];
test= var[1:3];
然后变量'test'将是[“test1”,“test2”,“test3”]
我如何在PHP中执行此操作?
答案 0 :(得分:20)
那将是array_slice($var, 1, 3)
。另见:http://php.net/manual/en/function.array-slice.php。
完整示例:
$var = array("test","test1","test2","test3");
$test = array_slice($var, 1, 3);