请帮助我如何才能得到我的预期结果,并提前致谢,对不起我的弱英语。
PHP:
git add --patch
输出:
$dog = implode(',', $data['dogbreed']);
$query .= "AND `dog_breeds`.`id` IN ('".$dog."')";
预期结果:
AND `dog_breeds`.`id` IN ('9,31')
阵列:
AND `dog_breeds`.`id` IN ('9','31')
答案 0 :(得分:2)
试试这个: -
$dog = implode("','", $data['dogbreed']);
$query .= "AND `dog_breeds`.`id` IN ('".$dog."')";
答案 1 :(得分:0)
更改您的行: -
$dog = implode(',', $data['dogbreed']);
于: -
$dog = implode("','", $data['dogbreed']);
您的代码可以正常使用。( 不要更改任何其他内容 )
在此检查输出: - https://eval.in/784234
注意: -
请不要更改此行: -
$query .= "AND `dog_breeds`.`id` IN ('".$dog."')";
答案 2 :(得分:0)
这是改变。试试这个
$data['dogbreed'] = array(9,10);
$dog = implode('","', $data['dogbreed']);
print $query = 'AND dog_breeds.id IN ("'.$dog.'")';