Difference between revisions of "FOREACH"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Iterate over each element of an array or member of an object
 
Iterate over each element of an array or member of an object
 
  
 
==Syntax==
 
==Syntax==
Line 9: Line 8:
  
 
ENDFOR
 
ENDFOR
 
  
 
==See Also==
 
==See Also==
[[AADD()]], [[AAVERAGE()]], [[ABROWSE()]], [[ACHOICE()]], [[ACLASS()]], [[ACOL()]], [[ACOPY()]], [[ADDPROPERTY()]], [[ADEL()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMEMBERS()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[AROW()]], [[ARRAY()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[CLASS - Scoping]], [[COMPOBJ()]], [[COPY TO ARRAY]], [[CREATEOBJECT()]], [[DECLARE]], [[DEFINE CLASS]], [[DIMENSION]], [[DISPLAY CLASSES]], [[DO WHILE]], [[DODEFAULT()]], [[FOR]], [[GATHER]], [[IN_ARRAY()]], [[LIST CLASSES]], [[LOADOBJECT()]], [[LOCAL]], [[METHOD]], [[NEWOBJECT()]], [[OBJECT()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[PRIVATE]], [[PUBLIC]], [[REMOVEPROPERTY()]], [[RELEASE]], [[RESTORE]], [[REQUIRE_ONCE()]], [[SAVE]], [[SAVEOBJECT()]], [[SCATTER]], [[SET CLASSLIBRARY]], [[SQL SELECT]], [[WITH]]
+
[[AADD()]], [[AAVERAGE()]], [[ACLASS()]], [[ACOPY()]], [[ADDPROPERTY()]], [[ADEL()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMEMBERS()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[ARRAY()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[CLASS - Scoping]], [[COMPOBJ()]], [[COPY TO ARRAY]], [[CREATEOBJECT()]], [[DECLARE]], [[DEFINE CLASS]], [[DIMENSION]], [[DISPLAY CLASSES]], [[DO WHILE]], [[DODEFAULT()]], [[FOR]], [[GATHER]], [[IN_ARRAY()]], [[LIST CLASSES]], [[LOADOBJECT()]], [[LOCAL]], [[METHOD]], [[NEWOBJECT()]], [[OBJECT()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[PRIVATE]], [[PUBLIC]], [[REMOVEPROPERTY()]], [[RELEASE]], [[RESTORE]], [[REQUIRE_ONCE()]], [[SAVE]], [[SAVEOBJECT()]], [[SCATTER]], [[SET CLASSLIBRARY]], [[SQL SELECT]], [[WITH]]
 
+
  
 
==Description==
 
==Description==
 
The FOREACH...ENDFOR command is used to iterate over each element in an array or member in an object.  The <array> must be the name of an existing array or object.  The <value> is a reference to be loaded with the contents of each element or member in turn.  Using the <key> => <value> syntax, the member names of an object or associative array can also be accessed.
 
The FOREACH...ENDFOR command is used to iterate over each element in an array or member in an object.  The <array> must be the name of an existing array or object.  The <value> is a reference to be loaded with the contents of each element or member in turn.  Using the <key> => <value> syntax, the member names of an object or associative array can also be accessed.
 
  
 
==Example==
 
==Example==
Line 32: Line 28:
 
endfor
 
endfor
 
</code>
 
</code>
 
==Products==
 
Recital, Recital Server, Recital Web
 
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]

Revision as of 08:56, 16 November 2011

Purpose

Iterate over each element of an array or member of an object

Syntax

FOREACH <array> AS <value> | FOREACH <array> AS <key> => <value>

<statements>

ENDFOR

See Also

AADD(), AAVERAGE(), ACLASS(), ACOPY(), ADDPROPERTY(), ADEL(), ADESC(), ADIR(), AELEMENT(), AFIELDS(), AFILL(), AINS(), ALEN(), AMAX(), AMEMBERS(), AMIN(), APPEND FROM ARRAY, ARRAY(), ASIZE(), ASORT(), ASTORE(), ASTRING(), ASUBSCRIPT(), ASUM(), CLASS, CLASS - Methods, CLASS - Parameters, CLASS - Properties, CLASS - Scoping, COMPOBJ(), COPY TO ARRAY, CREATEOBJECT(), DECLARE, DEFINE CLASS, DIMENSION, DISPLAY CLASSES, DO WHILE, DODEFAULT(), FOR, GATHER, IN_ARRAY(), LIST CLASSES, LOADOBJECT(), LOCAL, METHOD, NEWOBJECT(), OBJECT(), PRINT_HTML(), PRINT_JSON(), PRINT_R(), PRINT_XML(), PRIVATE, PUBLIC, REMOVEPROPERTY(), RELEASE, RESTORE, REQUIRE_ONCE(), SAVE, SAVEOBJECT(), SCATTER, SET CLASSLIBRARY, SQL SELECT, WITH

Description

The FOREACH...ENDFOR command is used to iterate over each element in an array or member in an object. The <array> must be the name of an existing array or object. The <value> is a reference to be loaded with the contents of each element or member in turn. Using the <key> => <value> syntax, the member names of an object or associative array can also be accessed.

Example

numbers = array(1,2,3,4,5,6,7,8,9,10)
foreach numbers as elem
    ? elem * elem
endfor
 
// associative array
private myarray = array("Name" => "Recital", "Description" => "database")
foreach myarray as key => value
    echo "key=" + key + " value=" + value + "\n"
endfor