当被迭代以输出与字符串不同的内容时,我试图获取数组中的最后一项。
if (count($this->condition) > 1) {
$i=0;
while ($i < count($this->condition)){
if ($i == (count($this->condition) -1)) {
foreach ($this->condition as $key => $value){
$query .= $value['columns']." = ".$value['value'];
}
} else {
foreach ($this->condition as $key => $value){
$query .= $value['columns']." = ".$value['value']." AND ";
$i++;
}
}
}
} else {
foreach ($this->condition as $key => $value){
$query .= $value['columns']." = ".$value['value'];
}
}
但是,它不断添加 AND,这意味着$i == (count($this->condition))
永远不会正确。
我该如何解决这个问题?