|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Sat Dec 15, 2018 1:37 am Post subject: Use FIRST without foreach |
|
|
Hello.
I have an array
$val > $key
sub-data $number
- main data {$data1}
- main data {$data2}
- main data {$data3}
i have a foreach loop in the template that gets the multiple lines of $val.
each of the $val variables is an array (key).
what i CAN do is do a foreach loop to get the $number, which is also an array. However I do not know what the value (key) of this $number is in advance.
but i DO know there will ONLY be one number for that array. in the sub-array (main data) there are three values i want to extract.
my main question:
I was wondering if I cam do just ONE foreach loop to get the three values, instead of doing 2-3 foreach loops.
For example
TOP foreach loop. example)
:- get 1st value (car)
$car.first.name (get name of car)
$car.first.size (get size of car)
$car.first.color (get color of car)
:- get 2nd value (shoe)
$shoe.first.name (get name of shoe)
$shoe.first.size (get size of shoe)
$shoe.first.color (get color of shoe)
I do not know what the first "key" is in advance,
will this be possible without doing a 2nd foreach loop ? (i dont see the point as there will only be 1 key / sub-array)
i hope that makes sense ?
PS - I did try the above, but i got an error :) |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Dec 17, 2018 7:26 am Post subject: |
|
|
Show the actual template code. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|