radalin Posted October 12, 2006 Share Posted October 12, 2006 I have question about javascript and array system. I'm using javascript in my web site and I would like to enable a language selection on it. I'm using language options from php side. an associative array, containing values like $lang["Hello"] => "Hello", and this goes on. Is there a way to do this with javascript? I mean is there a such an assosiative array option in javascript (which I do not think it's possible.). I have intended to use a getLang function which takes an argument about lang and with switch statements it returns the right value. Well that's ok but it will take a lot of time if I have thousand cases. Any idea is welcome.Thanks... Link to comment https://forums.phpfreaks.com/topic/23757-javascript-arrays/ Share on other sites More sharing options...
fenway Posted October 12, 2006 Share Posted October 12, 2006 Yes, JS support associative arrays a.k.a. hashes:var myAA = {};myAA['key1'] = 'value1';Strictly speaking, you can mix arrays and hashes, but don't (read: don't use numbers as the keys). Link to comment https://forums.phpfreaks.com/topic/23757-javascript-arrays/#findComment-107951 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.