This shows you the differences between two versions of the page.
uphp:functions:array_resize [2021/01/28 09:36] admin created |
uphp:functions:array_resize [2021/09/13 05:57] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======array_resize====== | ||
- | |||
- | < | ||
- | |||
- | Resize an indexed array | ||
- | |||
- | ====Description==== | ||
- | |||
- | <well size=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | </ | ||
- | |||
- | ====Parameters==== | ||
- | |||
- | < | ||
- | |||
- | < | ||
- | |||
- | ====Return Values==== | ||
- | |||
- | < | ||
- | |||
- | ====Example==== | ||
- | |||
- | ===Create an indexed array and resize it | ||
- | |||
- | <code php> | ||
- | < | ||
- | |||
- | $arr=indexed_array(4, | ||
- | | ||
- | // fill it up | ||
- | for ($i=0; | ||
- | $arr[$i]=$i; | ||
- | } | ||
- | | ||
- | print(sizeof($arr)); | ||
- | |||
- | array_resize($arr, | ||
- | print_r($arr); | ||
- | | ||
- | array_resize($arr, | ||
- | print_r($arr); | ||
- | ?></ | ||
- | </ | ||
- | |||
- | 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_keys()]] - Return keys for an < | ||
- | |||
- | [[sizeof()]] - Return the number of elements in an < | ||
- | |||
- | [[print_r()]] - Dump the contents of an < | ||
- | |||
- | [[uphp: | ||