User Tools

Site Tools


uphp:functions:array

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

uphp:functions:array [2017/04/10 13:10]
jeff
uphp:functions:array [2021/09/13 05:57]
Line 1: Line 1:
-======array====== 
- 
-<badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge> 
- 
-Create an <html><b><span style="color:green">array<span style="color:black"></b></html>, with optional values 
- 
-====Description==== 
- 
-<well size="sm"> 
-<html> 
-<span style="font-size:125%;color:green">array 
-<span style="color:black"> 
-</html> 
-[[array]] ( 
-<html> [ 
-<span style="color:green">mixed 
-<span style="color:blue">$value 
-<span style="color:black">[, ...] ] ) 
-</html> 
-</well> 
- 
-====Parameters==== 
- 
-<html><b><span style="color:blue">$value<span style="color:black"></b></html>(s):  Optional comma separated list of values of any type (<html><b><span style="color:green">string<span style="color:black"></b></html>, <html><b><span style="color:green">int<span style="color:black"></b></html>, <html><b><span style="color:green">float<span style="color:black"></b></html>, <html><b><span style="color:green">array<span style="color:black"></b></html>) 
- 
-====Return Value==== 
- 
-<html><b><span style="color:green">Array<span style="color:black"></b></html>:  empty or with values as specified 
- 
-====Examples==== 
- 
-**Creating Arrays:** 
- 
-<code php> 
-<?  
-  $arr=array(); // create a blank array 
-  $arr[0]='Item 1'; 
-  $arr[]='Item 2'; // automatically appends the value to the next available key 
-  $arr[2]='Item 3'; 
-    
-  $arr2=array(1,2,3,4); // array of integers 
-   
-  $arr3=array("one",2,3.33333,$arr); // mixed array, elements of type: string, integer, float, array 
-?> 
-</code> 
- 
-**Key/Value Pairs:** 
- 
-<code php> 
-<pre><?  
-  $arr=array(); // create a blank array 
-  $arr['name']='John'; 
-  $arr['age']=33;  
-    
-  // iterate through the array and print out all keys and their associated values 
-  for ($i=0; $i < sizeof($arr); $i++) { 
-    $key=array_key($arr,$i); 
-    print("Key at Index ".$i." is ".$key." and value is ".$arr[$key]."\r\n"); 
-  } 
-?></pre> 
-</code> 
- 
-The above example will output: 
-<code> 
-Key at Index 0 is name and value is John 
-Key at Index 1 is age and value is 33 
-</code> 
- 
-====Note==== 
- 
-An [[indexed array]] is a more efficient way to store variables in memory if the size and data type is known beforehand. The [[array()]] function creates a hashed <html><b><span style="color:green">array<span style="color:black"></b></html>, which consumes much more memory per element. 
- 
-====See Also==== 
- 
-[[indexed_array()]] - Create an <html><b><span style="color:green">array<span style="color:black"></b></html> of a specific type and size 
- 
-[[sizeof()]] - Return the number of elements in an <html><b><span style="color:green">array<span style="color:black"></b></html> 
- 
-[[print_r()]] - Dump the contents of an <html><b><span style="color:green">array<span style="color:black"></b></html> to the current output 
- 
-[[array_key()]] - Return the key for an <html><b><span style="color:green">array<span style="color:black"></b></html> index 
- 
-[[array_keys()]] - Return keys for an <html><b><span style="color:green">array<span style="color:black"></b></html> that has key/value pairs 
- 
-[[uphp:variables|uPHP Variable Types and Limits]] 
  
uphp/functions/array.txt · Last modified: 2021/09/13 05:57 (external edit)