I have the following associative array called $woo_post_category:
array(1) { [0]=> object(stdClass)#5839 (10) { ["term_id"]=> int(796) ["name"]=> string(20) "Womens Comfort Bikes" ["slug"]=> string(20) "womens-comfort-bikes"
I'm attempting to loop through the array and pull out the value association for the name key. I have the following code:
foreach($woo_post_category as $key_category => $value_category) {
if ( $key_category == 'name') {
echo 'Product is in Category:' . ' ' . $value_category;
}
}
I get the error :
PHP Catchable fatal error: Object of class stdClass could not be converted to string
Can anyone point out the issue here, thanks
$value_categoryis object of stdClass and you are trying to echo it. try$value_category->term_id.