I want to get a specific value out of a MySql database.
I have:
SELECT option_value
FROM wp_options
WHERE option_name = 'DevloungePluginSeriesAdminOptions'
Which outputs:
a:4:{s:11:"add_content";s:4:"true";s:7:"content";s:45:"155000009-9a5sg2t42q2k0159ko8hkdo85hjlu69j";s:11:"show_header";s:4:"true";s:14:"comment_author";s:4:"true";}
I think this is some sort of array. I don't know how handle it. I only want the 155000009-9a5sg2t42q2k0159ko8hkdo85hjlu69j
part of the string.
How can I get just 155000009-9a5sg2t42q2k0159ko8hkdo85hjlu69j
?
This data is in serialized format. You need to unserialize it before extracting the array value.
Suppose result object is $result, then following code will work:
$option_value = unserialize( $result->option_value );
$output = $option_value['content'];
put the value in a variable and unserialize:
$val = unserialize( $val );
You'll get a PHP array as a result, inspect it with
print_r( $val );