0

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?

1
  • 2
    Unsewialize that string and grab it from the array. Then fix your software not to store data in serialized strings. Commented Apr 25, 2013 at 20:36

2 Answers 2

1

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'];
Sign up to request clarification or add additional context in comments.

Comments

0

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 );

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.