0

I'm using CSV Import Suite for WooCommerce. One of the columns has to be a serialized array.

I'm trying to find out, how the serialize function in PHP works, as I need to recreate that in Excel. I have a simple array:

array(0 => 'text', 2 => 'some other text')

which gives me:

a:2:{i:0;s:4:"text";i:2;s:15:"some other text";}

What's the logic of how the serialized string is built?

1
  • There's probably a better solution here. Why do you need to recreate it in Excel? Commented Nov 16, 2014 at 9:42

2 Answers 2

2

To break down your example:

a:2:{i:0;s:4:"text";i:2;s:15:"some other text";}

  • array with 2 items
  • key is an integer: 0, with a string value of length 4, containing 'text'.
  • key is an integer: 2, with a string value of length 15, containing 'some other text'

Whether you should actually attempt this is another thing though. There's probably a better solution to the root problem.

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

Comments

0

It looks like this is something like a:2 where a stands for array, 2 is element count. Then you got i (integer), its value, ; as separator. then another element, s (string), its length and the value.

Comments

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.