| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Pulling value from multi-dimensional array | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() Is there a way to pull a single value directly from a multidimensional array? I have looked through the Smarty documentation and some PHP books I have but no luck.
I use the array to populate a dropdown menu and I want to show the selected name, not the underlying value, in a template. I could do this in the PHP file and assign a $makename variable to use or I think it would be more correct to retrieve the name in the template. Also, the array is dynamic based on what year you have selected. Example array: Array (37) 0 => Array (2) makeid => "58" makename => "Acura" 1 => Array (2) makeid => "73" makename => "Audi" 2 => Array (2) makeid => "31" makename => "BMW" 3 => Array (2) makeid => "45" makename => "Buick"
__________________
Adam X-Cart Gold 4.4.5 - Live X-Cart Gold 4.1.11 - Retired X-Payments 1.0.4 CDSEO Pro EWD Hosting |
|||||||
#2
|
|||||||
|
|||||||
![]() In Smarty:
{$array.index.makeid} e.g. {$array.0.makeid} would pull the makeid out of $array[0] |
|||||||
#3
|
|||||||
|
|||||||
![]() Thanks for the input. I guess my question wasn't specific enough.
This array is called $makes and when a selection is made in the drop down menu that it populates, then $make is set to the makeid in the array. IE BMW is selected so now $make = 31. Now that we have the $makes array and a value for $make, can I get BMW back out to use in a template, because it's more useful than having 31 as a vehicle make. Thanks.
__________________
Adam X-Cart Gold 4.4.5 - Live X-Cart Gold 4.1.11 - Retired X-Payments 1.0.4 CDSEO Pro EWD Hosting |
|||||||
|
|||
X-Cart forums © 2001-2020
|