Jump to content

serialize or implode?


jeff5656

Recommended Posts

Hi

 

Use serialize.

 

Serialize gives you something that isn't really human readable, but using unserialize can give you the array back as an array.

 

Implode just joins the array together into a string (and won't really work with multi dimensional arrays).

 

All the best

 

Keith

Link to comment
Share on other sites

Hi

 

Use serialize.

 

Serialize gives you something that isn't really human readable, but using unserialize can give you the array back as an array.

 

Implode just joins the array together into a string (and won't really work with multi dimensional arrays).

 

All the best

 

Keith

 

Yes, however if this is a fixed number of numbers with some significance that you may want to search for etc., then often it may be better to store each number in its own column (assuming a single dimension).  Depends upon what exactly your doing and how you'll use the data.

 

BTW, nice sig kickstart!

Link to comment
Share on other sites

It's funny that other thread you mentioned.  I have exclusively used extra tables instead of storing an array, because I never learned how to store and retrieve arrays!  So now I  am trying to use an array to store it instead of making a whole new table in the database.  But I agree using tables in a relational database is much more intuitive to me, but only because that's all I know...

Link to comment
Share on other sites

If the array DOES only contain numbers and it's only 1 dimension, I would use implode().  There's an advantage in debugging when you have human readable data, as well as having it take less space.  But be aware that implode() will convert all of false, null and "" to an empty string, so you won't be able to distinguish between those.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.