Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.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_Arrays - Fatal编程技术网

如何仅在php中打印数组数据

如何仅在php中打印数组数据,php,arrays,Php,Arrays,我从查询结果中得到了这个返回值 Array ( [0] => stdClass Object ( [password] => $2y$10$6D7S2gNkcDciJ7g5z/8sie79iV3FCGhGUCFCPHU3cNNdeUVUbLfQC ) ) 这是我的问题 $sql = "SELECT `$fields` FROM `$table` WHERE `$column` {$operator} '$value'"; if($this->_query = $this-&g

我从查询结果中得到了这个返回值

Array ( [0] => stdClass Object ( [password] => $2y$10$6D7S2gNkcDciJ7g5z/8sie79iV3FCGhGUCFCPHU3cNNdeUVUbLfQC ) )
这是我的问题

$sql = "SELECT `$fields` FROM `$table` WHERE `$column` {$operator} '$value'";
if($this->_query = $this->_pdo->prepare($sql)) {
    if($this->_query->execute()) {
        $this->_result = $this->_query->fetchAll(PDO::FETCH_OBJ);
        $this->_count = $this->_query->rowCount();
    } else {
        return $this->_error = true;
    }
}

print_r($this->_result);
现在,我只想显示或打印数组数据,这是
$2y$10$6D7S2gNkcDciJ7g5z/8SIE79IV3FCGHGUCCFPHU3CNNDEUVULFQC


提前感谢您的帮助D

可以使用方括号中的键访问数组元素,例如
$arr[$key]。
对象的属性可以使用
->
操作符访问,例如
$this->name

如果您只需要打印,这就足够了:


print\r($this->\u result[0]->password

你知道如何访问一个对象的属性和数组的值吗?如果你想让它使用
$this->\u result[0]['password']
你应该使用
PDO::FETCH\u ASSOC
。你想把对象转换成数组吗?我编辑了你的答案,因为
print\r($this->\u result[0]->password)中没有缩进
但后来我发现您在
密码
之间有反勾号-因此我对您的原始答案进行了回滚。@Pengun如果您觉得答案对您有帮助,您可以接受它。:P