I have an array that has some data that looks like this
我有一个数组有一些看起来像这样的数据
$valueOptions = array(
'order_shipping_data_firstname' => Mage::helper('orders2csv')->__('order shipping firstname'),
'order_shipping_data_lastname' => Mage::helper('orders2csv')->__('order shipping lastname'),
'order_shipping_data_region' => Mage::helper('orders2csv')->__('order shipping region'),
'order_shipping_data_street' => Mage::helper('orders2csv')->__('order shipping street'),
'order_shipping_data_city' => Mage::helper('orders2csv')->__('order shipping city')
);
I need to combine the firstname and last name fields but can't figure out a solution. This is the only file in the module that references anything lastname / first name / name so it's calling it externally from within the magento framework. Ideally they would be stored in variables and I could just combine them $fullname = $first . $last etc but this won't work in arrays.
我需要结合名字和姓氏字段,但无法找出解决方案。这是模块中唯一引用任何姓氏/名字/名称的文件,因此它从magento框架内部调用它。理想情况下,它们将存储在变量中,我可以将它们组合起来$ fullname = $ first。 $ last等但这在数组中不起作用。
I don't understand the usage of =>
too well but I know if I edit the right hand side and make this : => Mage::helper('orders2csv')->__('order shipping fullname')
the option will appear where I want (in a dropdown), so I guess I'm trying to combine 'order_shipping_data_firstname'&'order_shipping_data_lastname'
and put it before this, but within the array?
我不太了解=>的用法但是我知道如果我编辑右边并且这样做:=> Mage :: helper('orders2csv') - > __('order shipping fullname')选项将出现在我想要的地方(在下拉列表中),所以我想我正在尝试将'order_shipping_data_firstname'和'order_shipping_data_lastname'组合在一起并将其放在此之前,但是在数组中?
I've also tried starting another array in a variable and inserting the variable in the valueOptions array but this broke.
我也尝试在变量中启动另一个数组,并在valueOptions数组中插入变量,但这已经破坏了。
2 个解决方案
#1
3
$foo = array(
'bar' => array(
"hello",
"world"
),
);
var_dump($foo);
array nested in array
数组嵌套在数组中
#2
1
Try this:
$orders = Mage::helper('orders2csv');
$valueOptions = array(
'order_shipping_data_firstname' => $orders->__('order shipping firstname'),
'order_shipping_data_lastname' => $orders->__('order shipping lastname'),
'order_shipping_data_fullname' => $orders->__('order shipping firstname').' '.$orders->__('order shipping lastname'),
'order_shipping_data_region' => $orders->__('order shipping region'),
'order_shipping_data_street' => $orders->__('order shipping street'),
'order_shipping_data_city' => $orders->__('order shipping city')
);
Or this:
$orders = Mage::helper('orders2csv');
$valueOptions = array(
'order_shipping_data_firstname' => $orders->__('order shipping firstname'),
'order_shipping_data_lastname' => $orders->__('order shipping lastname'),
'order_shipping_data_fullname' => $orders->__('order shipping fullname'),
'order_shipping_data_region' => $orders->__('order shipping region'),
'order_shipping_data_street' => $orders->__('order shipping street'),
'order_shipping_data_city' => $orders->__('order shipping city')
);
#1
3
$foo = array(
'bar' => array(
"hello",
"world"
),
);
var_dump($foo);
array nested in array
数组嵌套在数组中
#2
1
Try this:
$orders = Mage::helper('orders2csv');
$valueOptions = array(
'order_shipping_data_firstname' => $orders->__('order shipping firstname'),
'order_shipping_data_lastname' => $orders->__('order shipping lastname'),
'order_shipping_data_fullname' => $orders->__('order shipping firstname').' '.$orders->__('order shipping lastname'),
'order_shipping_data_region' => $orders->__('order shipping region'),
'order_shipping_data_street' => $orders->__('order shipping street'),
'order_shipping_data_city' => $orders->__('order shipping city')
);
Or this:
$orders = Mage::helper('orders2csv');
$valueOptions = array(
'order_shipping_data_firstname' => $orders->__('order shipping firstname'),
'order_shipping_data_lastname' => $orders->__('order shipping lastname'),
'order_shipping_data_fullname' => $orders->__('order shipping fullname'),
'order_shipping_data_region' => $orders->__('order shipping region'),
'order_shipping_data_street' => $orders->__('order shipping street'),
'order_shipping_data_city' => $orders->__('order shipping city')
);