-1

我想使用array_diffmysql 查询的结果,$REQUEST这里的结果是我尝试过的:

while($resultarray3 = mysql_fetch_array($result3)) 
{
$Bestand = $resultarray3['Bestand']
}
$Ergebnis = array_diff($_REQUEST['Menge'], $Bestand);

我通过使用它得到了这个错误:Warning: array_diff(): Argument #2 is not an array in /var/www/html/lager_management/warenkorb.php on line 143

数组 $Bestand 的示例:

Array ( [0] => 20 [1] => 250 [2] => 90 ) 

数组 $Menge 的示例:

Array ([0] => 10 [1] => 45 [3] => 80 )
4

2 回答 2

0

use the array, not simple var

$Bestand[] = $resultarray3['Bestand'];
于 2012-11-27T08:13:39.973 回答
0

You are replacing the varible each time in loop. Try this

$Bestand =array(); while($resultarray3 = mysql_fetch_array($result3)) { $Bestand[] = $resultarray3['Bestand'] } $Ergebnis = array_diff($_REQUEST['Menge'], $Bestand);

Need to change/Modify

$Bestand=array()

and

$Bestand[] = $resultarray3['Bestand']
于 2012-11-27T08:13:47.427 回答