note 72217 added to function.array-pad
| From: | hk at osu1 dot php dot net | Date: | Mon, 08 Jan 2007 10:15:19 +0000 |
| Subject: | note 72217 added to function.array-pad | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121416@lists.php.net to get a copy of this message | ||
A simple example for array_pad()
the syntax is as follows: array_pad(array(), (+/-)int, value)
where "array" is the array to which the value is to be added,
"(+/-) int" is a value that decides the length of the array(it should be greater than the
length of the array.
if its a negative number then the value will be added at the left of the array else it will be added
to the right.
"values" denotes the value to be added to the array
lets try an example:
<?php
$digits = array();
$digits[0] = 1;
$digits[1] = 2;
$digits[2] = 3;
$arraypad = array_pad($digits, -4, "0");
print_r($arraypad);
?>
output:
Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 )
----
Server IP: 203.199.124.111
Probable Submitter: 203.109.123.149 (proxied: 203.109.123.149)
----
Manual Page -- http://www.php.net/manual/en/function.array-pad.php
Edit -- https://master.php.net/note/edit/72217
Del: integrated -- https://master.php.net/note/delete/72217/integrated
Del: useless -- https://master.php.net/note/delete/72217/useless
Del: bad code -- https://master.php.net/note/delete/72217/bad+code
Del: spam -- https://master.php.net/note/delete/72217/spam
Del: non-english -- https://master.php.net/note/delete/72217/non-english
Del: in docs -- https://master.php.net/note/delete/72217/in+docs
Del: other reasons-- https://master.php.net/note/delete/72217
Reject -- https://master.php.net/note/reject/72217
Search -- https://master.php.net/manage/user-notes.php