Re: [PHP] Alter an Array Key

2007-07-17 Thread Richard Lynch
On Sat, July 14, 2007 8:09 am, Stut wrote: > Craige Leeder wrote: >> 1. Don't modify $_POST > > Why not? Other portions of a web application will too easily be "confused" by what you've modified as the application grows. Far better to have your "clean" data in a different array than to go poking

Re: [PHP] Alter an Array Key

2007-07-14 Thread Robert Cummings
On Sat, 2007-07-14 at 14:09 +0100, Stut wrote: > > > 3. I'm not sure Roberts solution would work. I think it might result > > in an endless loop, and timeout your script. > > I always worry about adding or removing elements while iterating through > an array. I generally build up an array of key

Re: [PHP] Alter an Array Key

2007-07-14 Thread Robert Cummings
On Sat, 2007-07-14 at 01:57 -0400, Craige Leeder wrote: > > 3. I'm not sure Roberts solution would work. I think it might result > in an endless loop, and timeout your script. It works fine. Cheers, Rob. -- ... SwarmBuy.com - http://www.swa

Re: [PHP] Alter an Array Key

2007-07-14 Thread Stut
Craige Leeder wrote: 1. Don't modify $_POST Why not? 2. You controll the name of the array keys with the form. Why is there any need to change them form PHP's side of things? That's an assumption. A reasonable one in most cases, but not necessarily the case. 3. I'm not sure Roberts solu

Re: [PHP] Alter an Array Key

2007-07-13 Thread Craige Leeder
1. Don't modify $_POST 2. You controll the name of the array keys with the form. Why is there any need to change them form PHP's side of things? 3. I'm not sure Roberts solution would work. I think it might result in an endless loop, and timeout your script. - Craige -- PHP General Mailing List

Re: [PHP] Alter an Array Key

2007-07-13 Thread Richard Lynch
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

Re: [PHP] Alter an Array Key

2007-07-13 Thread Jim Lucas
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. Thanks, OD sure use str_replace in the value of the key name string. But, that probably doesn't answer your question. Why don't you supply us with an example of h

Re: [PHP] Alter an Array Key

2007-07-13 Thread Robert Cummings
On Fri, 2007-07-13 at 15:36 -0500, 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. $value ) { if( strpos( $key, '_' ) !== false ) { $_POST[str_replace( '_', '', $key )] = $value; unset