Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 来自数组的回显值_Php_Sql_Arrays_Echo - Fatal编程技术网

Php 来自数组的回显值

Php 来自数组的回显值,php,sql,arrays,echo,Php,Sql,Arrays,Echo,我正在wordpress数据库上运行一个查询,以计算wp_fruit表中“apple”值的出现次数,如下所示 $count = $wpdb->get_results("SELECT COUNT(*) as count FROM wp_fruit WHERE value='apple'" ); 它返回 array(1) { [0]=> object(stdClass)#446 (1) { ["count"]=> string(3) "238" } } Array ( [0] =

我正在wordpress数据库上运行一个查询,以计算wp_fruit表中“apple”值的出现次数,如下所示

$count = $wpdb->get_results("SELECT COUNT(*) as count FROM wp_fruit WHERE value='apple'" );
它返回

array(1) { [0]=> object(stdClass)#446 (1) { ["count"]=> string(3) "238" } } Array ( [0] => stdClass Object ( [count] => 238 ) ) array(1) { [0]=> object(stdClass)#445 (1) { ["count"]=> string(3) "238" } } Array ( [0] => stdClass Object ( [count] => 238 ) ) array(1) { [0]=> object(stdClass)#446 (1) { ["count"]=> string(3) "238" } } Array ( [0] => stdClass Object ( [count] => 238 ) )

我所追求的值是238,如何将其回显?

$count
是一个行对象数组,在这种情况下,只有一个:

echo $count[0]->count;
如果您使用
$row
而不是
$count
,可能更有意义

echo $row[0]->count;

因此,您正在访问第一行(第0行)的count列(object属性)。

谢谢您的帮助,现在就有意义了