unemployment Posted June 2, 2011 Share Posted June 2, 2011 I can't seem to append my array values. I am using a php multidimentional array and I don't think I am going down far enough into the array. My array is set up like this in php Array ( [users] => Array ( [0] => Array ( [row_id] => 1 [0] => Tom [1] => Cruise [2] => tomcruise ) [1] => Array ( [row_id] => 21 [0] => mrs tom [1] => cruise [2] => mrstomcruise ) ) ) and this is my JS for pulling the array data var search_array = eval('(' + resp + ')'); var search = search_array[0]; but search returns the users object and I need to get the name tom cruise out of the array. Any nice way to do that? Quote Link to comment Share on other sites More sharing options...
mrdhood Posted June 3, 2011 Share Posted June 3, 2011 search_array[0][1] returns Array ( 0 => array( 0 => '', 1 => 'THIS' ) ) or search_array[0][0][1] returns Array (0 => array (0 => array( 0 => '', 1 => 'THIS' ) ) ) Once you figure out which one of those gives you "tom" you can get cruise from changing 1 to 2 you can combine the two by doing something like var name = array[0] + " " + array[1]; you have to change "Array[0]" and "array[1]" to the right variables of course. Quote Link to comment Share on other sites More sharing options...
Adam Posted June 3, 2011 Share Posted June 3, 2011 To return "Tom": alert(search.users[0][0]); Quote Link to comment 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.