I am making a wordpress plugin, and I used a query to get all the data I need from the database but afterwards I can’t figure out how to parse it.
My query is:
$dbContent = $wpdb->get_results( "SELECT option_id, option_name, option_value FROM wp_options WHERE option_name LIKE '%Customizer%'" );
and I am showing it using:
$retval .= "<pre>";
$retval .= print_r($dbContent);
$retval .= "</pre>";
I get this, what I think is an array of arrays:
Array ( [0] => stdClass Object ( [option_id] => 119587 [option_name] => bfhCustomizer_price_1 [option_value] => 2.85 ) [1] => stdClass Object ( [option_id] => 119584 [option_name] => bfhCustomizer_option1 [option_value] => Leave-In Moisturizer ) [2] => stdClass Object ( [option_id] => 119585 [option_name] => bfhCustomizer_option2 [option_value] => Conditioner/Cleansing Conditioner ) [3] => stdClass Object ( [option_id] => 119586 [option_name] => bfhCustomizer_option3 [option_value] => Pure Oil Mixture ) [4] => stdClass Object ( [option_id] => 119588 [option_name] => bfhCustomizer_price_2 [option_value] => 3.45 ) [5] => stdClass Object ( [option_id] => 119589 [option_name] => bfhCustomizer_price_3 [option_value] => 1.99 ) [6] => stdClass Object ( [option_id] => etc...
Could someone tell me how to properly access this? I was trying to use something like $dbContent->option_id or $dbContent['option_id']but neither worked and I’m lost here now
It looks like you have an array of stdClass objects, so you can access it like this: