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, 4 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, 4 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

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098