PAD - PHP Application Driver


home | manual | reference | regression | sequence | develop | apps


Sequences - Xref - Options - increment


Concepts | Sequences | Actions | Examples | Reference

reference2


App: manual Page: lvl_occ/5
PHP
HTML
lvl_occ/5.pad
Result
<table border='1'>
{sequence '10..30', increment=10, name='row'}
<tr>
{sequence '1..5', name='column'}
<td>{$row | + $column}</td>
{/sequence}
</tr>
{/sequence}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35

App: manual Page: pages/levels_and_occurrences
PHP
HTML
pages/levels_and_occurrences.pad
Result
<p>
{block}
PAD is data driven, the PAD data concepts are named Level and Occurence
<br><br>
Below example: <br>
- Is two levels deep <br>
- The level 'row' has 3 occurences<br>
- The level 'column' has 5 occurences<br><br>
{/block}
{example 'lvl_occ/1', skipNames, center}
</p>

{block}
If not specifield for a PAD tag then default it has 1 occurence.
<br><br><hr><br>
Just for fun, below the above example implemented in a few different ways.
<br>
Hopefully all this magic will be explained in this manual.
{/block}

<p>
{sequence '2..12', name='xxx'}
{example 'lvl_occ/{$xxx}', skipNames{notFirst},skipOpen,skipHeader{/notFirst}{notLast},skipClose{/notLast}}
{/sequence}
</p>

PAD is data driven, the PAD data concepts are named Level and Occurence

Below example:
- Is two levels deep
- The level 'row' has 3 occurences
- The level 'column' has 5 occurences

PHP HTML Result
<?php

$row
[1] ['column'] [1] ['cell'] = 11;
$row [1] ['column'] [2] ['cell'] = 12;
$row [1] ['column'] [3] ['cell'] = 13;
$row [1] ['column'] [4] ['cell'] = 14;
$row [1] ['column'] [5] ['cell'] = 15;

$row [2] ['column'] [1] ['cell'] = 21;
$row [2] ['column'] [2] ['cell'] = 22;
$row [2] ['column'] [3] ['cell'] = 23;
$row [2] ['column'] [4] ['cell'] = 24;
$row [2] ['column'] [5] ['cell'] = 25;

$row [3] ['column'] [1] ['cell'] = 31;
$row [3] ['column'] [2] ['cell'] = 32;
$row [3] ['column'] [3] ['cell'] = 33;
$row [3] ['column'] [4] ['cell'] = 34;
$row [3] ['column'] [5] ['cell'] = 35;

?>
<table border='1'>
{row}
<tr>
{column}
<td>{$cell}</td>
{/column}
</tr>
{/row}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35

If not specifield for a PAD tag then default it has 1 occurence.



Just for fun, below the above example implemented in a few different ways.
Hopefully all this magic will be explained in this manual.

PHP HTML Result
<?php

$row
= [1,2,3];
$column = [1,2,3,4,5];

?>
<table border='1'>
{row}
<tr>
{column}
<td>{$row | * 10 | + $column}</td>
{/column}
</tr>
{/row}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
<?php

$short
= [ [ 11,12,13,14,15 ],
[
21,22,23,24,25 ],
[
31,32,33,34,35 ] ];

?>
<table border='1'> 
{short}
<tr>
{short}
<td>{$short}</td>
{/short}
</tr>
{/short}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
<?php

for ($row = 1; $row <= 3; $row++)
for (
$col = 1; $col <= 5; $col++)
$rows [$row] ['cols'] [$col] = TRUE;

?>
<table border='1'>
{rows}
<tr>
{cols}
<td>{echo (&rows:key*10) + &cols:key}</td>
{/cols}
</tr>
{/rows}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
<table border='1'>
{sequence '10..30', increment=10, name='row'}
<tr>
{sequence '1..5', name='column'}
<td>{$row | + $column}</td>
{/sequence}
</tr>
{/sequence}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
<table border='1'>
{sequence 3}
<tr>
{sequence 5}
<td>{echo ($-2 * 10) + $-1}</td>
{/sequence}
</tr>
{/sequence}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
<table border='1'>
{set $row = 10}
{while $row <= 30}
<tr>
{set $column = 1}
{while $column <= 5}
<td>{echo $row + $column}</td>
{increment $column}
{/while}
</tr>
{set $row = $row + 10}
{/while}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
{data 'row'   } (1,2,3)     {/data}
{data 'column'} (1,2,3,4,5) {/data}

<table border='1'>
{row}
<tr>
{column}
<td>{$row | * 10 | + $column}</td>
{/column}
</tr>
{/row}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
{data 'myJson'}
[
{ "column": [ 11, 12, 13, 14, 15 ] },
{ "column": [ 21, 22, 23, 24, 35 ] },
{ "column": [ 31, 32, 33, 34, 35 ] }
]
{/data}

{pad data='myJson'}
<table border='1'>
@start@
<tr>
{column}
<td>{$column}</td>
{/column}
</tr>
@end@
</table>
{/pad}
11 12 13 14 15
21 22 23 24 35
31 32 33 34 35
{data 'myCsv'}
AA,BB,CC,DD,EE
11,12,13,14,15
21,22,23,24,35
31,32,33,34,35
{/data}

<table border='1'>
{myCsv}
<tr>
{fields}
<td>{$value}</td>
{/fields}
</tr>
{/myCsv}
</table>
11 12 13 14 15
21 22 23 24 35
31 32 33 34 35
{data 'myYaml', 'http://localhost/pad/level_demo.yaml'}

<table border='1'>
{myYaml}
<tr>
{column}
<td>{$column}</td>
{/column}
</tr>
{/myYaml}
</table>
11 12 13 14 15
21 22 23 24 35
31 32 33 34 35
{data 'myXml', 'level_demo.xml'}

<table border='1'>
{myXml}
<tr>
{column}
<td>{$column}</td>
{/column}
</tr>
{/myXml}
</table>
11 12 13 14 15
21 22 23 24 35
31 32 33 34 35


App: sequence Page: random/parms

HTML RESULT
{sequence from=1, to='15..25'} {$sequence} {/sequence}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
{sequence from='-10..-5', to=10} {$sequence} {/sequence}
-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
{sequence rows='15..25'} {$sequence} {/sequence}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
{sequence rows=15, increment='1..10'} {$sequence} {/sequence}
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43
{sequence rows=15, increment='1...10'} {$sequence} {/sequence}
1 8 11 17 24 30 37 42 48 51 55 60 69 75 77
{sequence from='10..20', to='40..50', rows='10..20', increment='1...10'} {$sequence} {/sequence}
20 23 32 36 41


App: sequence Page: random/random

The sequence 'random'

HTML RESULT
{sequence:random rows=25, minimal=10, maximal=50              } {$sequence} {/sequence:random}
13 38 27 47 14 36 42 24 40 16 50 32 16 19 32 40 47 36 18 40 43 24 24 11 25
{sequence:random rows=25, minimal=10, maximal=50, unique      } {$sequence} {/sequence:random}
24 23 29 36 14 12 31 13 22 33 20 45 19 38 21 10 40 15 39 35 48 26 43 42 17
{sequence:random rows=15, minimal=10, maximal=50, increment=5 } {$sequence} {/sequence:random}
35 35 25 35 10 15 35 25 45 40 25 35 30 45 20


App: sequence Page: random/total

There are 3 ways for randomizing, a sequence (random), an option (randomly) and an action (randomize)

The sequence 'random'

HTML RESULT
{sequence:random rows=25, minimal=10, maximal=50              } {$sequence} {/sequence:random}
12 49 30 11 29 31 46 39 24 24 39 45 24 26 23 26 32 19 49 34 39 50 16 45 45
{sequence:random rows=25, minimal=10, maximal=50, unique      } {$sequence} {/sequence:random}
23 47 39 45 20 22 25 36 27 43 18 28 15 35 12 50 17 32 48 42 21 19 14 31 40
{sequence:random rows=15, minimal=10, maximal=50, increment=5 } {$sequence} {/sequence:random}
25 25 30 10 25 25 25 10 25 10 40 35 20 10 40

The sequence option 'randomly'

Here the loop index is randomly set before the sequence is executed.

HTML RESULT
{sequence loop,    rows=10, randomly, from=10, to=20} {$sequence} {/sequence}
19 18 13 15 11 11 15 10 13 12
{sequence power=2, rows=10, randomly, from=8,  to=16} {$sequence} {/sequence}
16384 1024 1024 1024 65536 2048 8192 256 4096
{sequence prime,   rows=10, randomly, to=1000       } {$sequence} {/sequence}
347 673 61 127 809 73 317 11 193 113

HTML RESULT
{sequence rows=4, randomly } 
{$sequence}
{/sequence}
7441494660605406362 116349884565657952 4167942868978544621 4440343012250680462
{sequence rows=4, randomly, from=10000000000, increment=10000000000} 
{$sequence}
{/sequence}
8982522460000000000 984252570000000000 2043061310000000000 4261280920000000000

HTML RESULT
{sequence from=10, to=20, push='mySeq'}
{mySeq randomly}         {$sequence} {/mySeq}
19 14 17 13 12 12 16 18 15 17 14
{mySeq randomly, unique} {$sequence} {/mySeq}
13 12 17 11 18 16 19 15

The sequence action 'randomize'

HTML RESULT
{sequence from=10, to=20, push='mySeq'}
{mySeq}                                     {$sequence} {/mySeq}
10 11 12 13 14 15 16 17 18 19 20
{mySeq randomize                          } {$sequence} {/mySeq}
13 12 10 14 18 15 19 17 16 11 20
{mySeq randomize=5                        } {$sequence} {/mySeq}
17 18 16 20 12
{mySeq randomize=5, duplicates            } {$sequence} {/mySeq}
14 20 16 14 17
{mySeq randomize=5, orderly               } {$sequence} {/mySeq}
11 13 17 18 19
{mySeq randomize=5, orderly, duplicates   } {$sequence} {/mySeq}
14 14 15 17 17
{mySeq randomize=25                       } {$sequence} {/mySeq}
20 16 17 17 18 15 20 20 17 17 10 18 20 10 19 16 18 16 13 16 17 15 17 13 11
{mySeq randomize=25, orderly              } {$sequence} {/mySeq}
10 10 10 10 10 10 11 11 11 12 13 13 14 14 14 14 14 15 15 15 15 16 18 19 20
{mySeq randomize=25, atLeastOnce          } {$sequence} {/mySeq}
17 13 15 11 16 20 13 11 14 15 14 16 10 19 18 10 20 12 13 14 17 20 13 18 14
{mySeq randomize=25, atLeastOnce, orderly } {$sequence} {/mySeq}
10 10 10 10 11 11 11 11 12 13 13 14 14 14 15 16 16 16 17 17 18 19 20 20 20

The sequence 'random' - other usages of it

HTML RESULT
{sequence random='75%', from=1, to=1000, push='myRandom2'}
{myRandom2 action='count'} {$sequence} {/myRandom2}
743

HTML RESULT
{sequence random=4, from=1, to=1000, push='myRandom'}
{myRandom action='count'} {$sequence} {/myRandom}
250

Yes, it works

HTML RESULT
{sequence random, randomly, randomize, maximal=1000} {$sequence} {/sequence}
945 727 622 865 562 827 772 802 445 276


App: sequence Page: specials/basic

HTML RESULT
{sequence 10} {$sequence} {/sequence}
1 2 3 4 5 6 7 8 9 10
{sequence 10, increment=2} {$sequence} {/sequence}
1 3 5 7 9 11 13 15 17 19
{sequence from=10, to=20 } {$sequence} {/sequence}
10 11 12 13 14 15 16 17 18 19 20
{sequence from=10, to=20, increment=2} {$sequence} {/sequence}
10 12 14 16 18 20
{sequence from=10, to=20, step=3 } {$sequence} {/sequence}
10 13 16 19
{sequence from=10, to=20, multiple=3 } {$sequence} {/sequence}
12 15 18


App: sequence Page: specials/double

HTML RESULT
{sequence '5;10;15;20',  name='one'}
{sequence '15;20;25;30', name='two'}
{sequence one}                     {$sequence} {/sequence}
5 10 15 20
{sequence two}                     {$sequence} {/sequence}
15 20 25 30
{sequence one, append='two'}       {$sequence} {/sequence}
5 10 15 20 15 20 25 30
{sequence one, prepend='two'}      {$sequence} {/sequence}
15 20 25 30 5 10 15 20
{sequence one, combine='two'}      {$sequence} {/sequence}
5 10 15 15 20 20 25 30
{sequence one, merge='two'}        {$sequence} {/sequence}
5 10 15 20 25 30
{sequence one, intersection='two'} {$sequence} {/sequence}
15 20
{sequence one, difference='two'}   {$sequence} {/sequence}
5 10 25 30
{sequence one, onlyNow='two'}      {$sequence} {/sequence}
5 10
{sequence one, onlyStore='two'}    {$sequence} {/sequence}
25 30

HTML RESULT
{sequence '10..90', increment=10, name='one'}
{sequence '1..9',                 name='two'}
{sequence one}                  {$sequence} {/sequence}
10 20 30 40 50 60 70 80 90
{sequence two}                  {$sequence} {/sequence}
1 2 3 4 5 6 7 8 9
{sequence one, add='two'}       {$sequence} {/sequence}
11 22 33 44 55 66 77 88 99
{sequence one, subtract='two'} {$sequence} {/sequence}
9 18 27 36 45 54 63 72 81
{sequence one, multiply='two'}  {$sequence} {/sequence}
10 40 90 160 250 360 490 640 810
{sequence one, divide='two'}    {$sequence} {/sequence}
10 10 10 10 10 10 10 10 10


App: check Page: tableFun/fun_5_a
PHP
HTML
tableFun/fun_5_a.pad
Result
<table border='1'>
{sequence '10..30', increment=10}
<tr>
{sequence '1..5'}
{cell $-2 + $-1}
{/sequence}
</tr>
{/sequence}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35

App: check Page: tableFun/fun_5_b
PHP
HTML
tableFun/fun_5_b.pad
Result
<table border='1'>
{sequence '10..30', increment=10, name='row'}
<tr>
{sequence '1..5', name='column'}
{cell $row + $column}
{/sequence}
</tr>
{/sequence}
</table>
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35




home | manual | reference | regression | sequence | develop | apps

(c) 2003-2025 Herbert Groot Jebbink