我试图爆炸返回的数组,它只是不想显示。显然我做错了什么。这是我在爆炸时遇到问题的代码。
索引.php
include "class_client.php";
$client->set('place', 'home');
$client->placeLookup();
$client->screen($client->response()); //want to replace this to print the selected exploded data as shown at the bottom of this question
class_client.php
private $data = array();
private $response = NULL;
public function set($key, $value) {
$this->data[$key] = $value;
return $this;
}
private function get($key) {
return $this->data[$key];
}
public function response() {
return $this->response;
}
public function placeLookup() {
$this->response = $this->srv()->placeLookup(array('place' => $this->get('place')));
return $this;
}
输出
stdClass Object
(
[return] => stdClass Object
(
[fields] => stdClass Object
(
[entries] => Array
(
[0] => stdClass Object
(
[key] => place.status
[value] => HERE
)
[1] => stdClass Object
(
[key] => place.name
[value] => home
)
)
)
[operation] => place.lookup
[success] => TRUE
)
)
我想在 index.php 的输出中看到的唯一数据是;
HERE(来自条目数组中 [0] 中的 [value])
home(来自条目数组 [1] 中的 [value])
如果我可以在 class_client.php 中分解并将值作为新数组返回给 index.php(以最小化/隐藏 index.php 中的代码),我也会更喜欢。
谢谢!!