PHP array_pad() Function
Complete PHP Array Reference
Definition and Usage
The array_pad() function inserts a specified number of elements, with a
specified value, to an array.
Syntax
array_pad(array,size,value)
|
Parameter |
Description |
array |
Required. Specifies an array |
size |
Required. Specifies the number of elements in the array returned from the function |
value |
Required. Specifies the value of the new elements in the array returned from the function |
Tips and Notes
Tip: If you assign a negative size parameter, the function will insert
new elements BEFORE the original elements. (See example 2)
Note: This function will not delete any elements if the size parameter is
less than the original array's size.
Example 1
<?php
$a=array("Dog","Cat");
print_r(array_pad($a,5,0));
?>
|
The output of the code above will be:
Array ( [0] => Dog [1] => Cat [2] => 0 [3] => 0 [4] => 0 )
|
Example 2
With a negative size parameter:
<?php
$a=array("Dog","Cat");
print_r(array_pad($a,-5,0));
?>
|
The output of the code above will be:
Array ( [0] => 0 [1] => 0 [2] => 0 [3] => Dog [4] => Cat )
|
Complete PHP Array Reference
Make your web applications look like a million bucks
|
|
Most web applications today use boring methods to present data to their viewers using grids or simple HTML tables. FusionCharts induces "life" into the web applications by converting monotonous data into lively charts, gauges & maps.
FusionCharts works with all technologies like ASP, ASP.NET, PHP, ColdFusion, Ruby on Rails, JSP, HTML pages etc.
and connects to any database to render animated & interactive charts. It takes less than 15 minutes and no expertise
whatsoever to build your first chart and just a glance of it to captivate your audience. This fact is endorsed by our
12,000 customers and 150,000 users which include a majority of the Fortune 500 companies.
And yeah, your applications could look like a million bucks by spending just $69.
So go ahead, download your
copy of FusionCharts and start "wow-ing" your customers now!
|
|