i am converting a table from using serialized to normal arrays.

i started with this code:

a:1:{s:7:"Friends";a:2:{i:0;s:1:"4";i:1;s:1:"5";}}

i managed to get the serialized to show as a normal array,

array(1) {
  ["Friends"]=>
  array(2) {
    [0]=>
    string(1) "4"
    [1]=>
    string(1) "5"
  }
}

but now i'm stuck getting it back into the database and the query it will use for adding future friends to the table.

if i use comma seperation i think it will look something like:

Friends [0]4,[1]5

all help appreciated, thanks in advance.

    Why would you want to use a comma separated list in the database? If you don't have a very good reason you should normalize the database instead and solve it that way.

      Unless you have a very good reason, you should not be storing comma separated values in a database field. You should create another table and use foreign keys instead.

        Write a Reply...