Goat Posted December 3, 2009 Share Posted December 3, 2009 This isn't life or death question, but I was wondering if there is quicker way to make arrays than standard: $myArray = array('one'=>1, 'two'=>2); this might not seem like a lot of code but I tend to use arrays a lot (and arrays within arrays). So is there perhaps something shorter? Like in python: // not an actual php code $myArray = ['one'=>1, 'two'=>2]; I know php has an alternate syntax for some things, so maybe there is something for this. regards, Goat Link to comment https://forums.phpfreaks.com/topic/183804-alternative-array-syntax/ Share on other sites More sharing options...
mraza Posted December 3, 2009 Share Posted December 3, 2009 you can do like this $array['one'] = 'one'; $array['two'] = 'two'; $array['three'] = 'three'; Link to comment https://forums.phpfreaks.com/topic/183804-alternative-array-syntax/#findComment-970208 Share on other sites More sharing options...
Goat Posted December 3, 2009 Author Share Posted December 3, 2009 Thanks, but I already know that . That's even longer and it kind of defeats the purpose. Link to comment https://forums.phpfreaks.com/topic/183804-alternative-array-syntax/#findComment-970210 Share on other sites More sharing options...
trq Posted December 3, 2009 Share Posted December 3, 2009 I know the kind of shortcut your talking about and no, it doesn't exist. I know there was talk of this but I'm not sure it will ever go ahead. Link to comment https://forums.phpfreaks.com/topic/183804-alternative-array-syntax/#findComment-970214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.