Location: PHPKode > projects > Open Power Template > tests/Opt/instruction/foreach_1.txt
Test checks the basic iteration features.

>>>>templates/test.tpl
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!-- Print array keys and values -->
<opt:root>
<opt:foreach array="$data" index="idx" value="val">
{@idx},{@val}::
</opt:foreach>
</opt:root>

>>>>expected.txt
OUTPUT

>>>>result.txt
key1,Value 1::key2,Value 2::key3,Value 3::key4,Value 4::
>>>>data.php
	$view->data = array(
		'key1' => 'Value 1',
		'key2' => 'Value 2',
		'key3' => 'Value 3',
		'key4' => 'Value 4'
	);
Return current item: Open Power Template