开发者

How can I select a range of indexes from an array?

开发者 https://www.devze.com 2023-01-31 15:48 出处:网络
In python I would do this: var = ["test","test1","test2","开发者_运维百科test3"];

In python I would do this:

var = ["test","test1","test2","开发者_运维百科test3"];
test= var[1:3];

Then variable 'test' would be ["test1","test2","test3"]

How can I do this in PHP?


That would be array_slice($var, 1, 3). See also: http://php.net/manual/en/function.array-slice.php.

Complete example:

$var = array("test","test1","test2","test3");
$test = array_slice($var, 1, 3);
0

精彩评论

暂无评论...
验证码 换一张
取 消