Let\'s say my $_POST
variable looks like:
65
[action] => editpost
[originalaction] => editpo
Here's a cool ultra-php-neat way to use php array_walk to specify a generic prefix to remove:
$foo = array('k_foo' =>"bar",
'k_bar' =>"b0r",
'y_foo' =>"b5r",
'y_not' =>"b7r",
'k_not' =>"b1r");
$subsetArray = $foo;
$key_prefix = "k_";
array_walk($foo, 'removeUnwanted', array(&$subsetArray, $key_prefix));
var_dump ($subsetArray);
function removeUnwanted($value, $key, $array){
$prefix = $array[1];
$testArray = &$array[0];
if(strpos($key,$prefix) ===0){
unset($testArray[$key]);
}
}
Now you can just call array walk, with a copy of the array of values, and the prefix string.