0

I have an array that looks something like this

array( 'cars' => 10, 'trucks' => 20, 'computers' => 50 );

Now I want to store the field and value pairs in a database field. I also want to be able to retrieve it so the array will be in the same form as it was.

1 Answer 1

2

That's what serialize() is for

Slightly More Elaborated

The serialize() function gets (almost) any type of value as an arguments, and outputs a storable string.

When you want to retrieve the value from the database, you use unserialize()

Sign up to request clarification or add additional context in comments.

1 Comment

Oh that's right. I thought this only took the values, but is does take them in pairs. Really stupid of me, sorry. Will accept answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.