Jump to content

Array key value problem


RogerInHawaii

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/57792-array-key-value-problem/
Share on other sites

I don't think spaces are valid in a array key, also periods serve as linkers so it is assuming you are linking the phrase My Key and Thing together into an array key.  I'd just use a different key if its not a big issue, If you really need to use "spaces" you could try using a psedo space character and then strreplace it out when you need to echo out the key

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.