\Smarty_Internal_Runtime_Foreach

Foreach Runtime Methods count(), init(), restore()

Summary

Methods
Properties
Constants
init()
count()
restore()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$stack
N/A

Properties

$stack

$stack : array

Stack of saved variables

Type

array

Methods

init()

init(\Smarty_Internal_Template  $tpl, mixed  $from, string  $item, boolean  $needTotal = false, null|string  $key = null, null|string  $name = null, array  $properties = array()) : mixed

Init foreach loop - save item and key variables, named foreach property data if defined - init item and key variables, named foreach property data if required - count total if required

Parameters

\Smarty_Internal_Template $tpl
mixed $from

values to loop over

string $item

variable name

boolean $needTotal

flag if we need to count values

null|string $key

variable name

null|string $name

of named foreach

array $properties

of named foreach

Returns

mixed —

$from

count()

count(mixed  $value) : integer

[util function] counts an array, arrayAccess/traversable or PDOStatement object

Parameters

mixed $value

Returns

integer —

the count for arrays and objects that implement countable, 1 for other objects that don't, and 0 for empty elements

restore()

restore(\Smarty_Internal_Template  $tpl, integer  $levels = 1) 

Restore saved variables

will be called by {break n} or {continue n} for the required number of levels

Parameters

\Smarty_Internal_Template $tpl
integer $levels

number of levels