5

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.

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?

I've also tried starting another array in a variable and inserting the variable in the valueOptions array but this broke.

2 Answers 2

3
$foo = array(
    'bar' => array(
        "hello",
        "world"
    ),
);
var_dump($foo);

array nested in array

Sign up to request clarification or add additional context in comments.

1 Comment

Could you give me an example of how this would be applicable in my example. It seems that the Mage::helper('orders2csv')->__('order shipping street') part renders the dropdown menu - so I think I am trying to join the 'order_shipping_data_firstname' and 'order_shipping_data_lastname' party then Mage::helper('orders2csv')->__('order shipping fullname'),
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')
);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.