PDA

View Full Version : calendarcustomfields options field into array


kj_ugs
03-27-2007, 05:55 PM
I'm wondering how i extract all the custom options from the table field options in the calendarcustomfields table.

When i look in the database all the custom options seem to be stored in one field in a format that looks like indexes or an array or something. How do i extract each value and put it into an array using php and mysql?

I know how to query the database but i don't know how to seperate those values in that field.

For example, i want to take the data in that field...

a:6:{i:1;s:3:"Gig";i:2;s:10:"Club Night";i:3;s:10:"Networking";i:4;s:7:"Lecture";i:5;s:7:"Seminar";i:6;s:5:"Other" ;}

and put it into an array...
Gig night
Networking
Lecture
Seminar
Other

Any help on this would be greatfully appreciated.

Thanks

MarkPW
03-27-2007, 06:35 PM
Use unserialize($yourdata);

kj_ugs
03-27-2007, 06:44 PM
So I'd pull that field data into a variable called $yourdata and then use unserialize on it?

Thanks!

MarkPW
03-27-2007, 07:35 PM
Yes - use print_r() to test the output and (using your example) you should see the following:

Array ( [1] => Gig [2] => Club Night [3] => Networking [4] => Lecture [5] => Seminar [6] => Other )

kj_ugs
03-27-2007, 08:03 PM
Thanks Mark, that helps a lot :)

KJ