Destramic Posted October 10, 2011 Share Posted October 10, 2011 hey guys im tring to add entries to an array but im doing something wrong here is the code ive tried...if anyone can help please var found_entries = {"users":[]}; found_entries['users'].push("test"); var found_entries = Array(); found_entries.push("users" : "test"); the result im looking for is var array = {"users":[{"value1", "value2"}]}; thank you Quote Link to comment https://forums.phpfreaks.com/topic/248808-jquery-array/ Share on other sites More sharing options...
haku Posted October 11, 2011 Share Posted October 11, 2011 var users = [], array = {}; users.push("value1"); users.push("value2"); array.users = users; You shouldn't use 'array' as a variable name though - Array is a reserved word, and the two are easy to confuse. It makes it easy to make mistakes. Quote Link to comment https://forums.phpfreaks.com/topic/248808-jquery-array/#findComment-1278157 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.