RogerInHawaii Posted June 29, 2007 Share Posted June 29, 2007 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 More sharing options...
cooldude832 Posted June 29, 2007 Share Posted June 29, 2007 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 Link to comment https://forums.phpfreaks.com/topic/57792-array-key-value-problem/#findComment-286272 Share on other sites More sharing options...
teng84 Posted June 29, 2007 Share Posted June 29, 2007 $x=array('s p a c e'=>'1'); print_r($x); ^^code result Array ( [s p a c e] => 1 ) the space is still there is that what you mean Link to comment https://forums.phpfreaks.com/topic/57792-array-key-value-problem/#findComment-286279 Share on other sites More sharing options...
sasa Posted June 30, 2007 Share Posted June 30, 2007 i try <?php $MyArray['My Key.Thing'] = 37; print_r($MyArray); ?> output X-Powered-By: PHP/4.4.4 Content-type: text/html Array ( [My Key.Thing] => 37 ) where is problem? Link to comment https://forums.phpfreaks.com/topic/57792-array-key-value-problem/#findComment-286438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.