Q:

How do I post a two-dimensional array to an API

The issue I am facing may seem simple, but since I can't try it, it's becoming quite a nuisance.
I need to post data to an API. I'm doing this using cURL PHP, so I get the data from the form, store it inside variables and those variables inside an array to be sent, but one of those parameters I need  to send is an array itself:
This info is meant to describe a customer:
"administrative": false,
"alias_numbers": [
   {
      "ac": "858",
      "cc": 34,
      "number_id": 3161,
      "sn": "880961"
   },
   {
      "ac": "958",
      "cc": 34,
      "number_id": 3239,
      "sn": "514"
   },
   {
      "ac": "465",
      "cc": 34,
      "number_id": 3241,
      "sn": "363983"
   },
   {
      "ac": "858",
      "cc": 34,
      "number_id": 3243,
      "sn": "88085692"
   },
   {
      "ac": "951",
      "cc": 34,
      "number_id": 3245,
      "sn": "598217"
   }
],
"customer_id": 1,

I am not sure of how to assing the alias_numbers to their values inside my dataArray, there can be a max of 10, but this is being controlled inside the form. This is what I have come up with:  
$dataArray = array(
    "customer_id" => $subscriberCustomerId,
    "email" => $subscriberEmail,
    "username" => $subscriberComRegNum,
    "external_id" => $subscriberComRegNum,
    "primary_number" => array(
        "cc" => $subscriberPrimaryNumber["cc"],
        "ac" => $subscriberPrimaryNumber["ac"],
        "sn" => $subscriberPrimaryNumber["sn"]
    ),
    for ($i=0; $i < sizeof($arrayAliasNumbers); $i++) { 
        "alias_numbers" => array(
            "cc" => $arrayAliasNumbers[$i]["cc"],
            "ac" => $arrayAliasNumbers[$i]["ac"],
            "sn" => $arrayAliasNumbers[$i]["sn"]
        ),
    }
    "domain_id" => $subscriberDomainId,
    "administrative" => $subscriberAdministrative,
    "status" => $subscriberStatus
);

You can see there is a primary_number which didn't cause any trouble since there can only be one, but with these aliases I am totally lost.
Here you have the array I'm trying to send (This is from processmaker, hence the @= variables):
for ($i=1; $i <= 10; $i++) { 
    if (!isset(@@formSubscriberAliasNumGrid[$i]['subscriberAliasCc']) && !isset(@@formSubscriberAliasNumGrid[$i]['subscriberAliasAc']) && !isset(@@formSubscriberAliasNumGrid[$i]['subscriberAliasSn']) {
        break;
    }else{
        $subscriberAliasNumber[$i] = array(
            "cc" => @=formSubscriberAliasNumGrid[$i]['subscriberAliasCc'],
            "ac" => @=formSubscriberAliasNumGrid[$i]['subscriberAliasAc'],
            "sn" => @=formSubscriberAliasNumGrid[$i]['subscriberAliasSn']
        );

        $arrayAliasNumbers[$i] = [$subscriberAliasNumber[$i];
    }

Thank you for your help,
Best Regards!

A:

Make the array seperately and then add it to your array.
$tmp = [];

for ($i=0; $i < sizeof($arrayAliasNumbers); $i++) { 
    $tmp[] = [
                "cc" => $arrayAliasNumbers[$i]["cc"],
                "ac" => $arrayAliasNumbers[$i]["ac"],
                "sn" => $arrayAliasNumbers[$i]["sn"]
            ];
}

$dataArray = array(
    "customer_id" => $subscriberCustomerId,
    "email" => $subscriberEmail,
    "username" => $subscriberComRegNum,
    "external_id" => $subscriberComRegNum,
    "primary_number" => array(
        "cc" => $subscriberPrimaryNumber["cc"],
        "ac" => $subscriberPrimaryNumber["ac"],
        "sn" => $subscriberPrimaryNumber["sn"]
    ),
    "alias_numbers"  => $tmp,                       // <- added here
    "domain_id" => $subscriberDomainId,
    "administrative" => $subscriberAdministrative,
    "status" => $subscriberStatus
);

