User Tools

Site Tools


uphp:functions:array_resize

This is an old revision of the document!


array_resize

WMMEGA FW >= 2.1179 WM-M2 FW >= 3.1179

Resize an indexed array

Description

array_resize ( array $array, int $length )

Parameters

$array: An indexed array

$index: The number of elements to resize to. If this is larger than the current size, 0 values will be inserted at the end. If the value is smaller, the array will be chopped.

Return Values

none

Example

===Create an indexed array and resize it

<pre><?
 
  $arr=indexed_array(4,100);  // array of 100 floating point values
 
  // fill it up
  for ($i=0;$i<100;$i++) {
    $arr[$i]=$i;
  }
 
  print(sizeof($arr));
 
  array_resize($arr,50);
  print_r($arr);
 
  array_resize($arr,120);
  print_r($arr);
?></pre>

The above example will output:

Key at Index 0 is name and value is John
Key at Index 1 is age and value is 30
Key at Index 2 is status and value is 1

See Also

array() - Create an array, with optional values

array_keys() - Return keys for an array that has key/value pairs

sizeof() - Return the number of elements in an array

print_r() - Dump the contents of an array to the current output

uPHP Variable Types and Limits

uphp/functions/array_resize.1611826607.txt.gz · Last modified: 2021/09/13 05:56 (external edit)