Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to combine two arrays within an array in PHP?

Tags:

arrays

php

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.

like image 522
James Avatar asked Oct 05 '22 14:10

James


1 Answers

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

array nested in array

like image 141
Qian Avatar answered Oct 10 '22 10:10

Qian