I have a function:
wp_gdsr_blog_rating()
And when I print_r it it outputs this:
stdClass Object ( [count] => 20 [rating] => 3.7 [bayes_rating] => 3.7 [max_rating] => 5 [percentage] => 74 [voters] => 71 [votes] => 260.0 )
How do I grab and print only [voters] value?
try
$o = wp_gdsr_blog_rating();
echo $o->voters;
@Sandro Dzneladze, the function
wp_gdsr_blog_rating()
returning a standard class object say like
<?php
class Obj {
public $count = 20;
public $rating = 3.7;
public $voters = 71;
public $votes = 260.0;
}
$var = new Obj();
print_r($var);
echo '<br/>';
echo $var->votes;
?>
So it is same as you create a object of class and return it. So you can access as same as accessing the class object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.