开发者

Echo values of array

I have an array, which if i do a var_dump() looks like this:

array(5) { ["id"]=>  string(10) "2147483647" ["date"]=>  string(10) "130477开发者_如何学编程3322" ["twitteruser"]=>  string(9) "Username" ["twitterurl"]=>  string(103) "http://a2.twimg.com/profile_images/1070129036/30175_415127663488_509603488_44556621_2331814_n_normal.jpg" ["govequote"]=>  string(80) "text" } 

How can I echo each one selectivly, E.g

I want $image to equal ["twitterurl"]=> string(103) "http://a2.twimg.com/profile_images/1070129036/30175_415127663488_509603488_44556621_2331814_n_normal.jpg"


Maybe using foreach?

foreach($someArray as $key => $element)
{
    echo '["'.$key . '"] => ';
    var_dump($element);
}

On array like:

$someArray = array('a' => 'b');

Returns:

["a"] => string(1) "b" 

Demo


whatever the name of your array that you are dumping do this

$image = $arrayName['twitterurl'];


You can access the data in the array one of two ways:

$image = $arrayVariable["twitterurl"];

or

foreach($arrayVariable as $key => $value){
  if($key === "twitterurl")
  $image = $value;
}


$image = trim( $arr[ "twitterurl" ] );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜