【php开源代码栏目提醒】:网学会员--在 php开源代码编辑为广大网友搜集整理了:array_slice.php绩等信息,祝愿广大网友取得需要的信息,参考学习。
<?php
$input = array("a", "b", "two"=>"c", "d", "e");
$output = array_slice($input, 2); // 返回 "c", "d", and "e"
$output = array_slice($input, -2, 1); // 返回 "d"
$output = array_slice($input, 0, 3); // 返回 "a", "b", and "c"
// 输出部分数组成员,注意数组索引同原始数组索引的变化
print_r(array_slice($input, 2, -1));
echo "<br>";
//设定preserve_keys参数为true,保证数组索引和原来数组一致
//即元素c,d在input中索引为two和3,则新数组索引一样为two和3
print_r(array_slice($input, 2, -1, true));
?>