21287 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 242 Views |
-
Dropdown box poplated from 2-Diamentional array

29 June 2012 at 8:56pm
Hi Friends,
I am having a 2-Diamentional array like
[AED] => Array
(
[Name] => United Arab Emirates Dirham
[Amount] => 3.73723
)[ARS] => Array
(
[Name] => Argentine Peso
[Amount] => 4.60188
)I am working on a silverstripe form with a dropdown box.Now i need to add the values of options to the dropdownbox as the keys of array and text as the concatination of key and value pair as example below.
i.e <option value="AED">AED(Argentine Peso)</option>
<option value="ARS">ARS(Argentine Peso)</option> -
Re: Dropdown box poplated from 2-Diamentional array

30 June 2012 at 12:27pm
All you need to do is iterate through your current array and build a new one.
$input = // your current array
$output = array(); // new arrayforeach($input as $k => $v) {
$output[$k] = $k . ' ('. $v['Name'] .')';
}Then use $output as your source in the dropdown field.
| 242 Views | ||
|
Page:
1
|
Go to Top |


