Thursday, June 26, 2014

Extract variables from an object stdclass in PHP using get_object_vars




PHP code to dump $fte
<?php 
echo var_dump($fte) ;
?>
Output:
 array(1) { [0]=> object(stdClass)#34 (1) { ["sumfte"]=> string(18) "369.74986600875854" } }
To extract value  369.74986600875854 from this stdclass, we need to use get_object_vars
<?php 
 $ftesum=get_object_vars($fte[0]); 
echo $ftesum['sumfte'];
?>
which returns
369.74986600875854

No comments:

Post a Comment