0

I used a plugin to input data into a database. Now I am displaying the data and writing code to search/sort. My problem is that I am not familiar with arrays that are put into a single field in a database. I’m not even sure of the correct “name” for data in this format. So if anyone could please direct me to a tutorial or documentation, I would appreciate it. Here is a sample of the code contained in one field of the database.

a:4:{i:0;s:32:"Green";i:1;s:26:"Red";i:2;s:31:"Blue";i:3;s:33:"Yellow";}

Ultimately I will need to display this data with a <br/> separating each element in the array. I also need to understand it better so I can search the fields that are displayed this way. I also really want to learn about it, because I believe it is fairly common and I should understand it.

1
  • Can you post a link to the plugin that made this and send another sample line? Commented Jun 18, 2012 at 19:25

2 Answers 2

3

this data has been serialized so call

$array = unserialize($data);
print_r($array);

another popular encoding is JSON which you should also look into.

just so you know what is going on

  • "a:4" says what follows will be an array with 4 elements
  • "i:0" says this is the 0th index in the array
  • "s:32" says what comes next is a string
  • "Green" is that string
  • the rest just follows this pattern
Sign up to request clarification or add additional context in comments.

Comments

1

That data has been serialized. unserialize it to get the array back.

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.