![](/img/trans.png)
[英]PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20
[英]Adding in PHP returns string addition. 10+12=1012!!!! I need 10+12=22
我的代碼:
$gettotz=0;
while($mycartqry=mysqli_fetch_array($cartqry)){
$one=$mycartqry['nos'];
$two=$gettotz;
echo $gettotz.=$myVar+$myVar2;
}
db viz 中有兩個值,即 10 和 12。我的答案是 01012。我的答案應該是 22...請幫助
應該是這樣的:
$gettotz=0;
while ($mycartqry=mysqli_fetch_array($cartqry)){
$one = $mycartqry['nos'];
$gettotz += $one;
// what is `$myVar` and `$myVar2` is unclear
// but if they exists you can also add'em:
// $gettotz += $one + $myVar + $myVar2;
}
echo $gettotz;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.