0

I var_dumped a variable and got this, how can i show it properly?

Like,
<p> Name: <?php echo $Firstname.' '.$Lastname; ?>
Country: <?php echo $country; ?></p>

 <?php
 array(3) { 
        [0]=> object(stdClass)#19 (3) { 
                                    ["Firstname"]=> string(4) "John"
                                    ["Lastname"]=> string(4) "Lest"
                                    ["Country"]=> string(3) "USA" 
                                    }
        [1]=> object(stdClass)#20 (3) {
                                    ["Firstname"]=> string(5) "Larry" 
                                    ["Lastname"]=> string(4) "Jems" 
                                    ["Country"]=> string(6) "Canada" 
                                    } 
        [2]=> object(stdClass)#21 (3) { 
                                    ["Firstname"]=> string(3) "Jim"
                                    ["Lastname"]=> string(5) "Ricks" 
                                    ["Country"]=> string(7) "England" 
                                    }
    }
 ?>
alexn
  • 57,867
  • 14
  • 111
  • 145
NestedWeb
  • 1,657
  • 2
  • 15
  • 31

1 Answers1

0

stdClass is (kind of) an anonymous object. Firstname, Lastname and Country are properties. To access them:

echo $obj->Firstname
alexn
  • 57,867
  • 14
  • 111
  • 145
  • stdClass objects are inside an array, when i `echo $results[0]->$obj->$Firstname; `, it says undefined variable, actually i need to loop through all those objects. – NestedWeb Oct 06 '12 at 14:34
  • @NestedWeb: try `echo $results[0]->Firstname`. If you can't get the loop to work from there, you should really go back and re-read the PHP manual. – DCoder Oct 06 '12 at 14:36
  • @NestedWeb `$obj` was just an example since you did not provide the actual variable name. – alexn Oct 06 '12 at 14:42