1

i have in the following data format, i think it is j son i want to echo image in it but json decode is not working on it please help me integrating my coding into WordPress platform

a:5:{s:4:"name";s:36:"e4da3b7fbbce2345d7772b0674a318d5.jpg";s:4:"type";s:10:"image/jpeg";s:5:"error";i:0;s:4:"size";i:2795;s:10:"thumb_name";s:42:"e4da3b7fbbce2345d7772b0674a318d5_thumb.jpg";}
0

1 Answer 1

2

You will need to use unserialize() to convert the data to its original form:

$data = 'a:5:{s:4:"name";s:36:"e4da3b7fbbce2345d7772b0674a318d5.jpg";s:4:"type";s:10:"image/jpeg";s:5:"error";i:0;s:4:"size";i:2795;s:10:"thumb_name";s:42:"e4da3b7fbbce2345d7772b0674a318d5_thumb.jpg";}';
$decoded = unserialize($data);
// then you should be able to get the path to the image
print $decoded['name'];
Sign up to request clarification or add additional context in comments.

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.