How to pass associative array to php page in POST?

I am trying to use Magento 1.9 XmlConnect module to save the billing address function. The xml connect is action for this saveBillingAddressAction. In the method, saveBillingAddressActionone line tries to access the array from the POST variables, as shown below -

$data = $this->getRequest()->getPost('billing', array());

How to transfer an array from the client side to the server in the POST variable so that billingparam has an array with the necessary data?

Magento repository - CheckoutController.php .

+4
source share
1 answer

You can create arrays from form elements using square brackets [].

<input type="hidden" name="billing[]" value="billing-info1">
<input type="hidden" name="billing[]" value="billing-info2">
<input type="hidden" name="billing[]" value="billing-info3">

(.. 0=>'billing-info1',1=>'billing-info2' ..).

, :

<input type="hidden" name="billing[key0]" value="billing-info1">
<input type="hidden" name="billing[key1]" value="billing-info2">
<input type="hidden" name="billing[key2]" value="billing-info3">

:

'key0' => 'billing-info1',
'key1' => 'billing-info2',
'key2' => 'billing-info3'
+6

Source: https://habr.com/ru/post/1606647/


All Articles