PHP how to loop through a post array

后端 未结 6 1137
北恋
北恋 2020-11-30 10:31

I need to loop through a post array and sumbit it.

#stuff 1



        
6条回答
  •  天命终不由人
    2020-11-30 10:53

    I have adapted the accepted answer and converted it into a function that can do nth arrays and to include the keys of the array.

    function LoopThrough($array) {
        foreach($array as $key => $val) {
            if (is_array($key))
                LoopThrough($key);
            else 
                echo "{$key} - {$val} 
    "; } } LoopThrough($_POST);

    Hope it helps someone.

提交回复
热议问题