Associative Array and breakout
| From: | jml at spectrum dot net | Date: | Wed, 02 May 2001 06:57:16 +0000 |
| Subject: | Associative Array and breakout | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-661@lists.php.net to get a copy of this message | ||
Hi Again,
As an example, I have the following associative array
"OPTIONS"=>array(
"0"=>"- - -",
"1"=>"Blue",
"2"=>"Green",
"4"=>"Hazel",
"8"=>"Brown",
"16"=>"Black")
(This is part of a larger object, and I have lots of them),
this array is used to populate either checkboxes or
radiobuttons, the values represent bitvalues which allow me
to store multiple choices in a singular integer value,
(which btw all makes searching very easy in the database
using the 'AND' bitwise operator), anyways I've used the
Smarty 'html_options' to populate the select portion and
it's worked great, but now I'm having a problem that it
taxing my knowledge of arrays.
I need to format the options portion differently and the
'html_options' is no longer usable (I need to embed the
choices over a table, and some other stuff) So I really need
to get access in Smarty to the Key Portion and The Value
Portion of the array, When I assign the Array to a Variable
in Smarty and loop through it, I'm only getting the Value.
So
1) Should I strip out the Key and Value into 2 arrays and
assign those to Smarty, if so, is there a Php Function to do
this?
or
2) Is there a way to address the key and value in smarty
directly once an associative array has been passed?
or
3) Am I totally missing Something
Thanks,
Joe