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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.