gpt4 book ai didi

PHP-获取数组中的项目数

转载 作者:行者123 更新时间:2023-11-29 23:29:10 25 4
gpt4 key购买 nike

好的,所以我有一个 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] =>
)

我做错了什么?

最佳答案

你检查过$explode的内容了吗?在调用 _paying() 之前尝试 print_r($explode); 以确保有数据。

关于PHP-获取数组中的项目数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26698549/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com