On Fri, July 13, 2007 3:36 pm, OD wrote:
> Hello,
> Is there any easy way to alter a key's name?
>
> I would like to remove some underscores in the $_POST array keys.
Not directly, but:
$post = array();
foreach($_POST as $k => $v){
$k = str_replace('_', ' ', $k);
$post[$k] = $v;
}
You could dink with unset instead, but it's a Bad Idea to alter what
is actually in $_POST, imho.
And you also don't really want to add new elements to an array while
you iterate through it, generally... Though I think maybe foreach
does the right thing with that.
Better to build a new array and put the stuff you want into that.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php