PHP issue: Multiple ListIDs from an array...

My form is sending an array of IDs to my create function. FireBug shows this as:

listids[]    5cb76bb2fc5f08c71d1c7793b56232,a746b21b1941ef9d43854ff2e784ea23

No matter what I try, I keep getting a 400 error with Invalid ListIds.

If I hardcode it like the following it's ok:

'ListIDs' => array('5cb76bb2fc5f08c71d1c7793b56232','a746b21b1941ef9d43854ff2e784ea23'),

But none of the following work. Please help!?

'ListIDs' => array($postData['listids']); // won't work as it's an array inside an array
'ListIDs' => array(json_encode($postData['listids']));
'ListIDs' => array(implode(",", $postData['listids']));

makingmemark, 5 years ago

I've tried putting my id's in quotes:

$this->listids->addMultiOption ( "'" . $list->ListID . "'", $list->Name);

Firebug now shows:
listids[]    'a746b21b1941ef9d43854ff2e784e74c','5cb76bb2fc5f08c71d1c7793b56be882'

I'm then imploding them:
$lists = implode(",", $postData['listids']);

But the following still doesn't work: 'ListIDs' =>  array($lists),

Ergh!

makingmemark, 5 years ago

Worked it out. More a PHP/Zend issue than anything else - am my ineptitude of course...


$listString = $postData['listids'][0];
$lists = explode(",", $listString );

...

'ListIDs' => $lists

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free