我有一个数组有一些看起来像这样的数据
$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')
);
我需要结合名字和姓氏字段,但无法找出解决方案。这是模块中唯一引用任何姓氏/名字/名称的文件,因此它在magento框架内从外部调用它。理想情况下,它们将存储在变量中,我可以将它们组合起来$ fullname = $ first。 $ last等,但这不会在数组中工作。
我不太了解=>
的使用情况,但我知道如果我编辑右侧并执行此操作:=> Mage::helper('orders2csv')->__('order shipping fullname')
该选项将显示在我想要的位置(在下拉列表中) ),所以我想我试图合并'order_shipping_data_firstname'&'order_shipping_data_lastname'
并将其放在此之前,但是在数组中?
我还尝试在变量中启动另一个数组并在valueOptions数组中插入变量,但这已经破坏了。
答案 0 :(得分:3)
$foo = array(
'bar' => array(
"hello",
"world"
),
);
var_dump($foo);
数组嵌套在数组
中答案 1 :(得分:1)
试试这个:
$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')
);
或者这个:
$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')
);