Jump to content

Need to get values from Multidimentional Array


unemployment

Recommended Posts

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?

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.