sql - How to pull out certain value using php and this output -
i've come across weird scenario not know how code around. i'm creating json api wordpress site. i'm using connections plugin , trying pull out "original" image filename. output of sql command this:
{ ["options"]=> string(396) "a:4:{s:5:"entry";a:1:{s:4:"type";s:12:"organization";}s:5:"group";a:1:{s:6:"family";a:0:{}}s:4:"logo";a:2:{s:6:"linked";b:0;s:7:"display";b:0;}s:5:"image";a:3:{s:6:"linked";b:1;s:7:"display";b:1;s:4:"name";a:4:{s:9:"thumbnail";s:25:"invoicelogo_thumbnail.jpg";s:5:"entry";s:21:"invoicelogo_entry.jpg";s:7:"profile";s:23:"invoicelogo_profile.jpg";s:8:"original";s:24:"invoicelogo_original.jpg";}}}" } }
i'm using following command acquire that:
querystr = "select options {$wpdb->prefix}connections id= '{$_get['companyid']}'"; $options = $wpdb->get_results($querystr);
i'm not sure how pull out "original" part of code though it's not organized. appreciated.
what seeing results of php serialize
call
to @ original name this.
$decodedoptions = unserialize($options); $original = $decodedoptions["image"]["name"]["original"];
hope helps
as side note deserialized data looks
array ( [entry] => array ( [type] => organization ) [group] => array ( [family] => array ( ) ) [logo] => array ( [linked] => [display] => ) [image] => array ( [linked] => 1 [display] => 1 [name] => array ( [thumbnail] => invoicelogo_thumbnail.jpg [entry] => invoicelogo_entry.jpg [profile] => invoicelogo_profile.jpg [original] => invoicelogo_original.jpg ) ) )
Comments
Post a Comment