mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-12-12 09:29:47 +01:00
96 lines
1.7 KiB
Plaintext
96 lines
1.7 KiB
Plaintext
|
Foreach loop
|
||
|
-----
|
||
|
<?php
|
||
|
|
||
|
// foreach on variable
|
||
|
foreach ($a as $b) {}
|
||
|
foreach ($a as &$b) {}
|
||
|
foreach ($a as $b => $c) {}
|
||
|
foreach ($a as $b => &$c) {}
|
||
|
|
||
|
// foreach on expression
|
||
|
foreach (array() as $b) {}
|
||
|
|
||
|
// alternative syntax
|
||
|
foreach ($a as $b):
|
||
|
endforeach;
|
||
|
-----
|
||
|
array(
|
||
|
0: Stmt_Foreach(
|
||
|
keyVar: null
|
||
|
byRef: false
|
||
|
stmts: array(
|
||
|
)
|
||
|
expr: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
valueVar: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
)
|
||
|
1: Stmt_Foreach(
|
||
|
keyVar: null
|
||
|
byRef: true
|
||
|
stmts: array(
|
||
|
)
|
||
|
expr: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
valueVar: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
)
|
||
|
2: Stmt_Foreach(
|
||
|
keyVar: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
byRef: false
|
||
|
stmts: array(
|
||
|
)
|
||
|
expr: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
valueVar: Expr_Variable(
|
||
|
name: c
|
||
|
)
|
||
|
)
|
||
|
3: Stmt_Foreach(
|
||
|
keyVar: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
byRef: true
|
||
|
stmts: array(
|
||
|
)
|
||
|
expr: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
valueVar: Expr_Variable(
|
||
|
name: c
|
||
|
)
|
||
|
)
|
||
|
4: Stmt_Foreach(
|
||
|
keyVar: null
|
||
|
byRef: false
|
||
|
stmts: array(
|
||
|
)
|
||
|
expr: Expr_Array(
|
||
|
items: array(
|
||
|
)
|
||
|
)
|
||
|
valueVar: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
)
|
||
|
5: Stmt_Foreach(
|
||
|
keyVar: null
|
||
|
byRef: false
|
||
|
stmts: array(
|
||
|
)
|
||
|
expr: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
valueVar: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
)
|
||
|
)
|