好的,所以我有一个while循环,我循环遍历不同的用户:
$before = $data['autorenew_before'];
$refs=$dbh->prepare("SELECT * FROM users WHERE user_by=:userby AND expire <= unix_timestamp(CURRENT_TIMESTAMP + INTERVAL :before day)");
#$refs->bindParam(":userby",$data['username']);
$refs->bindParam(":userby",$userdata['username']);
$refs->bindParam(":before",$before);
$refs->execute();
然后我循环上面的查询:
while($refsData=$refs->fetch()){
$ids = "".$refsData['id'].",";
$explode = explode(",",$ids);
$outcome = _paying(number_format(getPriceList($data['rented_referrals']),2), 30, $data['username'], $explode);
}
这是_paying
函数:
function _paying($ceny, $dni, $username, $referrals_array){
//$ceny = 0.20
//Count referrals_array doesn't return anything.
$koszyk = $ceny * count($referrals_array);
return $koszyk;
}
由于count($referrals_array)
不起作用,上述功能无效。
编辑 - 1 :
print_r($explode);
给了我:
Array
(
[0] => 40231
[1] =>
)
Array
(
[0] => 40232
[1] =>
)
Array
(
[0] => 40233
[1] =>
)
Array
(
[0] => 40234
[1] =>
)
Array
(
[0] => 40235
[1] =>
)
Array
(
[0] => 55847
[1] =>
)
Array
(
[0] => 55848
[1] =>
)
Array
(
[0] => 90322
[1] =>
)
Array
(
[0] => 90323
[1] =>
)
Array
(
[0] => 90324
[1] =>
)
Array
(
[0] => 90325
[1] =>
)
Array
(
[0] => 90326
[1] =>
)
我做错了什么?
答案 0 :(得分:0)
您是否检查了$explode
的内容?
在致电print_r($explode);
之前尝试_paying()
以确保有数据。