Posted by David Smithz on 01/31/07 00:40
"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:<0r8ur2p751ajikm57gh5avfc05cahbci2e@
>
> It's difficult to advise without knowing exactly what you want to do but
> you could make a copy of the array changing the keys as necessary.
>
> foreach($array as $key=>$value){
> if($key=="key2"){
> $key="key number 2";
> }
> $temparray[$key]=$value;
> }
> $array=$temparray;
Guess that would be a way of achieving it. The details are that I have a
webform where I want text fields with a name of a certain format to get
emailed automatically.
E.g. if a input text element is called name="FIELDTOEMAILfirstname"
A php script will automatacially detect this and include the field in an
email that is sent. In this particular case the identifier part of the field
name is striped and inserted into the email is the remaining part of the
field followed by the contents. E.g.
firstname:field contents as user entered.
I have found this is a great way of adapting forms quickly and still having
the new fields automatically emailed.
However, to improve presentation in some cases, I want to be able to rename
the field name that is displayed in the email. So in the example above we
might want to replace firstname with "First Name".
If I could easily go through the array replacing the keys (As that is how
the email is generated, it just runs down an associating array printing
keyname followed by value) I thought this would add to this neat little
system.
But to be honest you are probably going to say I might as well just do the
last bit they way you have said above, but I'm open to suggestions.
Thanks
[Back to original message]
|