在 PHP 中使用带有 for 循环的数组值从数据库中获取数据

Get Data from database using array values with for loop in PHP

数组:

$ecodesAr = Array ( 
[0] => 1Z0-060 
[1] => 98-375 
[2] => 98-368 
[3] => 98-367 )

for($k=0; $k<count($ecodesAr); $k++){ 
$arrayTB[$k] = $this->Functions->exam('title', $ecodesAr[$k]); }                         
                                    
                                    

模态代码:

public function exam($q, $d) {
    $q = $this->db->where($q, $d)
                    ->get('exams');
    return $q->row();
}

结果:

Array ( 
[0] => 
[1] => 
[2] => 
[3] => stdClass Object ( [id] => 1091 [hot_exam] => 0 [top_exam] => 0 [category] => 114 [subcats] => 288 [slug] => 98-367 [sku] => OI5Ao [title] => 98-367 [name] => MTA Security Fundamentals [update] => 2021-09-16 [regular_price] => 130 [sale_price] => 59 [on_homepage] => 0 [on_request] => 0 [expired] => 0 [path_slug] => 98-367.pdf [questions] => 123 [demo_slug] => 98-367-demo.pdf [prc_price] => 65 [prc_demo] => 98-367-demo [prc_exam] => 98-367 [is_active] => 1 ) 
)

前 3 个值在输出中被跳过,只得到最后一个值,我想要所有数组数据反对值请帮助任何人!

$productsarry = Array ( 
    [0] => Milk 
    [1] => Cream 
    [2] => Sugar 
    [3] => Yougert
);
for($k = 0; $k < count($productsarry); $k++) { 
    $arrayTB[$k] = query("select slug, qty, name, price from exams where title ='$ecode'")->row(); 
}