我试图返回值作为数组,但未能阵列,返回值从PHP函数
函数调用
$rates = getamount($Id, $days, $date, $code);
功能
function getamount($Id, $days, $date, $code) {
// fetch data from database
// run whileloop
while() {
// Do other stuff
// Last get final output values
$rates['id'] = $finalid;
$rates['days'] = $finaldays;
// more and more
$rates['amount'] = $finalamount;
//If echo any variable here, can see all values of respective variable.
}
//If echo any variable here, can only see last value.
return $rates;
}
而在去年的功能外(需要这因此也将变量加载到会话中也作为阵列)
$compid = $rates['id'];
$totaldays = $rates['days'];
$totalamount = $rates['amount'];
试过几个解决方案,从SO,但不能让我的头围绕这个
如何设置while循环,它将无限运行,直到sc撕裂时间了。你永远不会得到回报。 –
是[while循环(http://php.net/manual/en/control-structures.while.php)看起来不正确 – 2pha
不能发布整个代码,这是我的最终完全好了, – Shehary