How to get value of an associative HTML array in PHP using a string?

前端 未结 3 1680
礼貌的吻别
礼貌的吻别 2021-01-29 08:19

Look I have a form like this:

I want t

3条回答
  •  遇见更好的自我
    2021-01-29 08:42

    You're WAY overthinking it. Anything you put in [] array notation in a form field's name will just become an array key. The following is LITERALLY all you need:

    
    
    $val = $_POST['foo']['bar']['baz']['qux'];
    

    You cannot use a string as an "address" into the array, not without insanely ugly hacks like eval, or parsing the string and doing a loop to dig into the array.

提交回复
热议问题