How to parse wordpress post_meta table values

I need to parse the wordpress post_meta strong> table , especially the "_ wp_attachment_metadata" field

For example:

Its value for the message id = 99

> a:6:{s:5:"width";s:3:"238";s:6:"height";s:3:"179";s:14:"hwstring_small";s:23:"height='96' > width='128'";s:4:"file";s:21:"2010/11/matt-lane.jpg";s:5:"sizes";a:1:{s:9:"thumbnail";a:3:{s:4:"file";s:21:"matt-lane-150x150.jpg";s:5:"width";s:3:"150";s:6:"height";s:3:"150";}}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}} 

I did not understand how it was compiled or how it can be analyzed outside of wordpress. The thing is, I have to download the latest articles with all the message datasets on the magento platform from wordpress.

please help me parse this data to get src's images.

Thanks in advance

+8
json parsing wordpress
source share
3 answers

Try:

 $a = unserialize(""); print_r($a); 

http://php.net/manual/en/function.unserialize.php

+17
source share

I understand:

There are two types of variables, for example:

  • a:6:
  • s:3:

a = array and 6 is the dimension of the array
s = string and 3 - string length

+7
source share

Thanks so much for Craig's quick reply.

Used the unserialize method and got everything from the string.

 Array ( [width] => 523 [height] => 523 [hwstring_small] => height='96' width='96' [file] => 2010/11/tee1.jpg [sizes] => Array ( [thumbnail] => Array ( [file] => tee1-150x150.jpg [width] => 150 [height] => 150 ) [medium] => Array ( [file] => tee1-300x300.jpg [width] => 300 [height] => 300 ) [post-thumbnail] => Array ( [file] => tee1-523x198.jpg [width] => 523 [height] => 198 ) ) [image_meta] => Array ( [aperture] => 0 [credit] => [camera] => [caption] => [created_timestamp] => 0 [copyright] => [focal_length] => 0 [iso] => 0 [shutter_speed] => 0 [title] => ) ) 

Here is the result, now you can take any image from the wordpress message meta_data p>

+2
source share

All Articles