Trying to parse out the $_POST key names that I don't want

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2010-12-30T15:47:02Z Indexed on 2010/12/30 15:54 UTC
Read the original article Hit count: 89

Filed under:
$post_keys = array_keys($_POST);
$special_keys = array();

for($i=0;$i<count($post_keys);$i++){
    if(strpos($post_keys[$i], "special") !== false){

        $special_keys[] = $post_keys[$i];

    }
}

I have numerous post vars with naming conventions such as special0, special0_time, special0_duration, special1, special1_time etc.... What I want to do is to find out how many main groups there are, so special0, special1 etc... The code I currently have searches all key names that have "special" in it, thus retrieving more than I want.

© Stack Overflow or respective owner

Related posts about php