Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Pulling value from multi-dimensional array

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-10-2009, 06:28 AM
 
AMMoyer AMMoyer is offline
 

Senior Member
  
Join Date: Nov 2008
Posts: 150
 

Default Pulling value from multi-dimensional array

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
Reply With Quote
  #2  
Old 02-10-2009, 08:51 AM
 
exsecror exsecror is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,284
 

Default Re: Pulling value from multi-dimensional array

In Smarty:

{$array.index.makeid} e.g. {$array.0.makeid} would pull the makeid out of $array[0]
Reply With Quote
  #3  
Old 02-10-2009, 09:18 AM
 
AMMoyer AMMoyer is offline
 

Senior Member
  
Join Date: Nov 2008
Posts: 150
 

Default Re: Pulling value from multi-dimensional array

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
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:45 AM.

   

 
X-Cart forums © 2001-2020