I have product ids like this 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);
}
how can I format json
with this code in for loop echo json
not working is there any other way plz help