PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<array_multisortarray_pop>
Last updated: Mon, 16 Jul 2012

array_pad

(PHP 4, PHP 5)

array_pad --  用值将数组填补到指定长度

说明

array array_pad ( array input, int pad_size, mixed pad_value )

array_pad() 返回 input 的一个拷贝,并用 pad_value 将其填补到 pad_size 指定的长度。如果 pad_size 为正,则数组被填补到右侧,如果为负则从左侧开始填补。如果 pad_size 的绝对值小于或等于 input 数组的长度则没有任何填补。

例子 1. array_pad() 例子

<?php
$input
= array (12, 10, 9);

$result = array_pad ($input, 5, 0);
// result is array (12, 10, 9, 0, 0)

$result = array_pad ($input, -7, -1);
// result is array (-1, -1, -1, -1, 12, 10, 9)

$result = array_pad ($input, 2, "noop");
// not padded
?>

参见 array_fill()range()




<array_multisortarray_pop>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST