Reward: yes, I put this before telling you guys what is the contest about.
*A link to your site on http://www.webdevlogs.com
*A review of your site on http://www.webdevlogs.com
Note: The reward does not apply to sites with content higher than R(ex. NC-17)).
The challenge:
Suppose you want to make a template system that complies the template syntax into PHP script(like smarty), and you want to implement a while loop system.
All you want to do is change this syntax
into
This is easy, but what if you suddenly want to let user to know the iteration of the loop? Now, the template will be like this
you can compile it into this
Ok, everything is fine, and here you will meet the CHALLENGE.
If the loop are nested, like:
How could you create a system that will know the right iteration for each one of the while loop so when {$iteration} is used, it is showing the iteration for the while loop it is in right now.
How the winner is decided:
The winner is the person writes a template parser that makes this template get complied and show the right result with the lowest time usage.
*A link to your site on http://www.webdevlogs.com
*A review of your site on http://www.webdevlogs.com
Note: The reward does not apply to sites with content higher than R(ex. NC-17)).
The challenge:
Suppose you want to make a template system that complies the template syntax into PHP script(like smarty), and you want to implement a while loop system.
All you want to do is change this syntax
| Code: |
| {while $expression}output stuff{/while} |
into
| Code: |
| <?php while($expression){ ?>
output stuff <?php } ?> |
This is easy, but what if you suddenly want to let user to know the iteration of the loop? Now, the template will be like this
| Code: |
| {while $expression}output stuff, and here out put the iteration:{$iteration}{/while} |
you can compile it into this
| Code: |
| <?php
$iteration = 1; while($expression){ ?> output stuff, and here out put the iteration: <?php ++$iteration;} ?> |
Ok, everything is fine, and here you will meet the CHALLENGE.
If the loop are nested, like:
| Code: |
| {while $expression}{while $expression2}output stuff{$iteration}{/while}{$iteration}{/while} |
How could you create a system that will know the right iteration for each one of the while loop so when {$iteration} is used, it is showing the iteration for the while loop it is in right now.
How the winner is decided:
The winner is the person writes a template parser that makes this template get complied and show the right result with the lowest time usage.
| Code: |
| <?php
$timeparts = explode(' ',microtime()); $starttime = $timeparts[1].substr($timeparts[0],1); $i = 0;?> {while $i<30} <?php $n = 0;?> {while $n < 20} $n+1:{$iteration}<br /> {/while} $i+1:{$iteration}<br /> {/while} <?php $timeparts = explode(' ',microtime()); $endtime = $timeparts[1].substr($timeparts[0],1); echo 'Time used:',bcsub($endtime,$starttime,6); ?> |
