loop through $_POST variables with similar names

后端 未结 7 768
南笙
南笙 2020-12-18 09:51

I have several $_POST variables, they are

$_POST[\'item_number1\']
$_POST[\'item_number2\']

and so on

I need to write a loop tha di

相关标签:
7条回答
  • 2020-12-18 10:15

    try:

    foreach($_POST as $k => $v)
    {
        if(strpos($k, 'item_number') === 0)
        {
            echo "$k = $v";
        }
    }
    

    In the above example, $k will be the array key and $v would be the value.

    0 讨论(0)
提交回复
热议问题