Click to See Complete Forum and Search --> : Array Key Value problem


RogerInHawaii
06-29-2007, 06:10 PM
I've discovered that when you do something like:


MyArray['My Key.Thing'] = 37;


the key value actually gets modified and becomes "My_Key_Thing". That is, it translates certain characters into underscores. In particular it translates spaces and decimal points. Maybe it also translates other characters.

Is there a way to tell it to NOT do that translation?

Or, if that's not possible, is there a function I can call that will do the same kind of translation so that I can produce a "proper" string myself for the key?

RogerInHawaii
06-29-2007, 08:07 PM
Actually, the problem actually only arises when the name of some form control ends up in the $_POST array. For example, if I have a control named "My Control" and the form gets submitted then the entry in the $_POST array actually gets a key value of "My_Control" instead of "My Control".

The solution MAY seem to be to simply not use spaces or decimal points in form controls. Howevere, I have a situation where some of my controls are dynamically generated and the names of those controls are a composite of the control type (e.g. "DeleteButton") and a file name, such as the name of the file that the button is intended to delete. Since I dont have control over what the name of the fie might be, and it may contain space characters and most likely will contain a decimal point, I've got a problem.

Any suggestions?

bluestars
06-30-2007, 01:33 PM
Do it differently. :(

I'd have a hidden input called "DeleteButtonFile", and its value would contain the filename.

It may be possible to prevent that conversion, but I don't know how. I'd just avoid the whole thing.

MrCoder
06-30-2007, 03:27 PM
What are you trying to do?

There has to be a better way of doing it that how you currently are.