XMen
XMen

Reputation: 30248

array value in php

In the following code , in the echo of preview why i am getting only h.

  echo "<pre>";
  print_r($thumb);
  echo $thumb=$thumb['thumb']."<br/>";
  echo $preview=$thumb['preview'];
  exit;

Array
(
    [thumb] => http://dtzhqpwfdzscm.cloudfront.net/4d52463406ce5.jpg
    [preview] => http://dtzhqpwfdzscm.cloudfront.net/4d5246345dac0.jpg
)
http://dtzhqpwfdzscm.cloudfront.net/4d52463406ce5.jpg
h

Please suggest thanks

Upvotes: 0

Views: 48

Answers (3)

Tobias
Tobias

Reputation: 7380

It´s because of this line:

echo $thumb=$thumb['thumb']."<br/>";

Remove the $thumb=

Upvotes: 0

zerkms
zerkms

Reputation: 254926

Because you've overwritten $thumb variable. Change to:

  echo "<pre>";
  print_r($thumb);
  echo $thumb['thumb']."<br/>";
  echo $thumb['preview'];
  exit;

Upvotes: 2

Pekka
Pekka

Reputation: 449435

Because you are turning the array into a string here:

$thumb=$thumb['thumb'] 

Upvotes: 2

Related Questions