开发者

how to get value from an array

how to get t开发者_开发问答he value 4500 to a variable

stdClass Object ( [total] => 4500 ) 

i tried like these

$abc['total']
$abc->total 

when i print the $abc->total

i got

Array ( [0] => stdClass Object ( [total] => 4500 ) )

please help me


echo $abc->total

should work.

If you want to output the value in a string, enclose it in curly brackets to be on the safe side:

echo "Value is {$abc->total}";

or use string concatenation:

echo 'Value is ' . $abc->total;


since you are not giving a large part of the PHP code i assume that code is correctly printed out

this answer works fine:

<?php
$abc = array('total' => 4500); // I've created an array with key='total' and val=4500
$abc = (object)$abc; // returns stdClass Object ( [total] => 4500 ) 
echo $abc->total; // it should print 4500
?>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜