Get the current array key inside foreach

后端 未结 3 1809
悲&欢浪女
悲&欢浪女 2021-02-10 23:01

Ok so, I am building something for my employer for them to input products, they have very specific requirements. I have a form with dynamically generated fields like so... (obvi

3条回答
  •  执笔经年
    2021-02-10 23:11

    Ok so, I have fixed it, with the help of you guys and the realization that i had been a little stupid and only edited the static part of the form to incorporate the dynamic key and not the ajax generated part which overwrites it.

    foreach ($_POST['attribute'] as $key => $attributes){
    echo $key.'+'.$attributes.'
    '; }

    Works perfectly. thanks for the tips guys.

提交回复
热议问题