实例首页
自学教程
IT工具箱
源代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>PHP array_slice() 实例 - 自学教程(runoops.com)</title> </head> <body> <?php // preserve 设置为 true,保留键名 $a=array("red","green","blue","yellow","brown"); print_r(array_slice($a,1,2,true)); // 不保留键名设置为 false(默认) $a=array("red","green","blue","yellow","brown"); print_r(array_slice($a,1,2,false)); // 注意两个数组的键是不一样的 ?> </body> </html>
运行结果: