How to get a subset of $_POST array with keys starting with a prefix

前端 未结 8 1626
栀梦
栀梦 2020-12-31 13:18

Let\'s say my $_POST variable looks like:

 65
    [action] => editpost
    [originalaction] => editpo         


        
8条回答
  •  [愿得一人]
    2020-12-31 13:57

    Another method:

    $formVars = $_POST;
    foreach ($formVars as $key=>$value) {
        if (strpos($key, 'empl_')===false) 
            unset($formVars[$key]);
    }
    

提交回复
热议问题