FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=17139&edit=1

ID: 17139
Updated by: alan@akbkhome.com
Reported By: chepa at inbox dot lv
-Summary: if use foreach in foreach - second foreach cannot use
first foreach values as v
+Summary: nested array properties are not supported
-Status: Open
+Status: Bogus
-Type: Bug
+Type: Feature/Change Request
Package: HTML_Template_Flexy
Package Version: 1.3.9
PHP Version: 5.2.1
Roadmap Versions:
New Comment:

-Summary: if use foreach in foreach - second foreach cannot use
first foreach values as v
+Summary: nested array properties are not supported
-Status: Open
+Status: Bogus
-Type: Bug
+Type: Feature/Change Request
Thank you for taking the time to write to us, but this is not
a bug.

foreach works as expected, however Flexy does not support heavily
nested array
properties. - it's a real mess to handle..

normally you would just make a method
function getPrice($value, $value2 $type)
{
return $value[$value2['shopname']]['prices'][$type];
}

then do this in the template
{getSomething(value,value2,#price_1#)}


Previous Comments:
------------------------------------------------------------------------

[2010-02-19 18:47:06] ohmygod

Description:
------------
if using array in array - cannot retrieve variable value from second
array using first array value as variable.


Test script:
---------------
{foreach:items,id,value}
<tr>
<td>{value[active]}</td>
<td><a href="/uimg/{value[primary_image]}">{value[name]}</a></td>
<td>{value[code]}</td>
{foreach:shops,id2,value2}
<td>
{value[value2[shopname]][prices][price_1]} <!-- OUTPUTS EXACTLY
WHAT I WROTE, NOT VALUE FROM ARRAY
{value[realshopname][prices][price_1]} OUTPUTS WHAT I NEED -->
{end:}
<td>{value[date_created]}</td>
</tr>{end:}

Expected result:
----------------
for example i hawe array: [119676]=>
array(8) {
["id"]=>
string(6) "119676"
["name"]=>
string(17) "Philips 42PF9831D"
["code"]=>
string(17) "philips_42pf9831d"
["primary_image"]=>
string(13) "1_119676l.gif"
["active"]=>
string(1) "N"
["date_created"]=>
string(10) "24.09.2007"
["realshopname"]=>
array(1) {
["prices"]=>
array(3) {
["price_1"]=>
string(7) "1169.00"
["price_2"]=>
string(4) "0.00"
["active"]=>
string(1) "N"
}
}
["secondshop"]=>
array(1) {
["prices"]=>
NULL
}
}

if using: {value[realshopname][prices][price_1]} i got right result;
if using value2['shop_name'] what value is exactly realshopname returns
this code :/

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedFeb 20, '10 at 1:37a
activeFeb 20, '10 at 1:37a
posts1
users1
websitepear.php.net

1 user in discussion

Alan: 1 post

People

Translate

site design / logo © 2022 Grokbase