CLiown
CLiown

Reputation: 13843

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) "1304773322" ["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"

Upvotes: 1

Views: 255

Answers (4)

publikz.com
publikz.com

Reputation: 961

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

Upvotes: 0

robx
robx

Reputation: 3123

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;
}

Upvotes: 0

Robik
Robik

Reputation: 6127

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

Upvotes: 1

mcgrailm
mcgrailm

Reputation: 17640

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

$image = $arrayName['twitterurl'];

Upvotes: 1

Related Questions