Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.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,此代码 $url = 'https://api.twitter.com/1.1/users/lookup.json'; $getfield = '?screen_name=bvb'; $requestMethod = 'GET'; $twitter = new TwitterAPIExchange($settings); $response = $twitter->setGetfield($getfield) ->buildOauth($url, $requestMetho

此代码

$url = 'https://api.twitter.com/1.1/users/lookup.json';
$getfield = '?screen_name=bvb';
$requestMethod = 'GET';

$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
    ->buildOauth($url, $requestMethod)
    ->performRequest();

$twitter_array = json_decode($response);

var_dump($twitter_array);
给我这个数组:

Array (
    [0] => stdClass Object (
        [id] => 14173315
        [id_str] => 14173315
        [name] => NBC News
        [screen_name] => NBCNews
        [location] => New York, NY
        [description] => The leading source of global news and information for more than 75 years. Facebook: https://anything Snapchat: https://anything
        [url] => http://anything
        [entities] => stdClass Object (
            [url] => stdClass Object (
                [urls] => Array (
                    [0] => stdClass Object (
                        [url] => http://anything
                        [expanded_url] => http://NBCNews.com
                        [display_url] => NBCNews.com
                        [indices] => Array (
                            [0] => 0
                            [1] => 22
                        )
                    )
                )
            )
        [description] => stdClass Object (
            [urls] => Array (
                [0] => stdClass Object (
                    [url] => https://anything
                    [expanded_url] => https://www.facebook.com/NBCNews
                    [display_url] => facebook.com/NBCNews... 

我拼命想把这些数据保存到一些变量中,比如
$twitter\u array[0]->name没有成功。你能告诉我我在干什么吗

它是JSON格式的吗?如果是的话,你在转换它吗?我刚刚用更多的代码更新了我的问题…你似乎已经在变量中有了它<代码>echo$twitter\u数组[0]->名称应打印NBC新闻
例如。仅供参考
json_decode($json,true)
将所有内容转换为数组而不是对象如果错误原因是输入错误-删除此问题。