我有这样的产品ID 1,2,3 in$product_ids
$product_ids = explode(',', $product_ids);
$product_ids = array_filter($product_ids);
foreach ($product_ids as $key => $product_id) {
$sth = $this->db->prepare("SELECT * FROM products Where id =:id ");
$sth->execute(array( ':id' => $product_id ));
$final_data = $sth->fetchAll();
echo json_encode($final_data);
}
我如何json
在for循环回显中使用此代码格式化json
不工作有没有其他方法请帮助