以下代码:
<?php
$col_names = array('n1','n2','n3','n4','n5');
$values = array(0,0,'NOW()',0,0);
$i = 0;
while($i<count($col_names)) {
if($values[$i] == 'NOW()') {
$qmarks[] = "NOW()";
} else {
$qmarks[] = '?';
}
$i++;
}
print_r($qmarks);
?>
结果如下:
Array
(
[0] => NOW()
[1] => NOW()
[2] => NOW()
[3] => NOW()
[4] => NOW()
)
它应该是这样的:
Array
(
[0] => ?
[1] => ?
[2] => NOW()
[3] => ?
[4] => ?
)
有人有想法吗?
答案 0 :(得分:2)
<?php
$col_names = array('n1','n2','n3','n4','n5');
$values = array(0,0,'NOW()',0,0);
$i = 0;
while($i<count($col_names)) {
if($values[$i] === 'NOW()') {
$qmarks[] = "NOW()";
} else {
$qmarks[] = '?';
}
$i++;
}
print_r($qmarks);
?>
将===
改为==