How to loop through multiple arrays at the same time (parallel)

后端 未结 2 426
梦如初夏
梦如初夏 2021-01-27 06:54

Oke so I don\'t know why this is so hard, all information I find is only for two arrays like array_combine.

I have 3 arrays that I get from dynamically created input fie

2条回答
  •  醉梦人生
    2021-01-27 07:35

    If you are sure that for each item information is under one and the same key in all arrays, you can do following:

    $article_id = $_REQUEST['article_id'];
    $article_descr = $_REQUEST['article_descr'];
    $article_ammount = $_REQUEST['article_amount'];
    
    foreach ($article_id as $id => $value) {
        echo 'Article id: ' . $value . '
    '; echo 'Article description: ' . $article_descr[$id] . '
    '; echo 'Article ammount: ' . $article_ammount[$id] . '
    '; }

提交回复
热议问题