0 Replies Latest reply: May 18, 2012 2:34 PM by whatalotofrubbish RSS

    How do I access the results of a multi dimensional array.

    whatalotofrubbish Community Member

      I created an array from a recordset using the following code copied from a post by David Powers

       

      $results = array();

      do {

        $results[] = $row_recordsetName;

      } while ($row_recordsetName = mysql_fetch_assoc($recordsetName));

       

      My recordset has two fields in the $results array, index and name, and the array also seems to generateanother index called whichit uses to reference the rows- in this case, [0] to [2]

       

      When printed using the print_r function, it shows results like the following:

       

      Array[0] => Array([index]=>:2[name]=>Microsoft)

      => [1] => Array([index]=>:5[name]=>Facebook)  *

      => [2] => Array([index]=>:6[name]=>Adobe)

       

       

      I have another recordset  called employers that has a pointer into the array which holds the same value as the Array[index].

       

      In this recordset is a row with  a pointer value of 5, and I want to access and print out the Array[ name] whose value =  "Facebook"  from the example array element above*, where Array[index] = 5.

      How would I do it?

       

      To put it in simulatede SQL, how do I select  $results[name] from $results where $results[index] = $row_employerset[pointer]   and print it?