Instead of something like:Array ( [0] => 'MAX_FILE_SIZE'=>'1000000', 'actual_type'=>'Map', 'obj_name'=>'teagfsagsd', 'map_region'=>'gasdfadsf', 'map_type'=>'Dungeon', 'map_connections'=>'wgrgawg' )
I'm just trying to build a smaller array from the contents that were actually filled out in the post and I'd like to reference them by their original form names.Array ('MAX_FILE_SIZE'=>'100000', 'ACTUAL_TYPE'=>'Map', so on and so forth... )
Code: Select all
<?
// accept the POST...
$rawPost = $_POST;
// call the function to create new lightPost...
cleanPost($rawPost);
function cleanPost($heavyPost)
{
foreach($heavyPost as $key => $value)
{
if (!empty($value))
{
$string .= "'" . $key . "'=>'" . $value . "', ";
}
}
// remove the trailing space and comma...
$lightPost = substr_replace($string,"",-2);
// build a new array
global $post;
$post = array($lightPost);
print_r($post);
} // end FUNC
?>