Saving multiple values into a select attribute

Permalink
I can't find documentation how to do this. I'm creating pages programmatically from a recordset of data.

I have an array of credit cards (Visa,Amex,MC,Discover) in my source DB and a corresponding Select Attribute (credit_cards) with matching values/options.

Each record contains 1 or more of the possible CC options.

How can I insert these?

Saltwater
 
Saltwater replied on at Permalink Reply
Saltwater
Actually I was close in my first attempt but had spaces in my string so when I tried to setAttribute using an array, that spaces caused mismatches.

This code worked for me
$cards = explode(",",str_replace(' ','',$card_string_from_db));
$page->setAttribute('credit_cards',$cards);