0

I import data from WordPress. It is a WebDirectory 2.0 that saves the data as a "strange" string in a database.

Example:

s:95:"a:2:{s:3:"url";s:39:"http://www.google.com/";s:4:"text";s:13:"Website";}";

I have tried json_decode() and unserialize(). Both do not work. They return the string as it is. I can see, this is an array with two values, but how this can be parsed in PHP? In what format this string can be?

2
  • 3
    It looks like a string that has been serialized twice, so it must be unserialized twice. Commented Feb 10, 2021 at 22:57
  • 1
    No, that's not JSON Commented Feb 10, 2021 at 22:57

1 Answer 1

1

If you have this:

echo serialize(serialize(['url'=>'http://www.google.com/','text'=>'Website']));

The output will be

s:71:"a:2:{s:3:"url";s:22:"http://www.google.com/";s:4:"text";s:7:"Website";}";

But what you have is

s:95:"a:2:{s:3:"url";s:39:"http://www.google.com/";s:4:"text";s:13:"Website";}";

Which is different. See, s:95 != s:71, among other elements.

Or this is not a real data or by some reason it's generating extra chars, and causing the problem. I would check how the encoding from both PHP and database to see if all matches.

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

1 Comment

I think OP changed the string to remove sensitive data.

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.