Jump to content

Multi-Dimensional Arrays - How to create


Wildhalf

Recommended Posts

Hi i want to search my table for a few specific enteries shown in the code below

 

$multi_sql = "SELECT spon_email_1, spon_email_2,spon_email_3,spon_email_4,spon_email_5 FROM worthatry_spon WHERE aff_email = '[email protected]'";
	$multi_res = mysql_query($multi_sql) or die("An internal error has occured!<br />Unable to run the following query:<br /><pre>" . $qry. "</pre><br /><br />" . mysql_error());
	$multi = mysql_fetch_array($multi_res);	

 

Now this SQL state works and returns exactly what i want it to. now once i have this information i would like to turn this array into a multidemensional array.

 

 

I want the array to be 3 levels. ie ARRAY[1st_email][2nd_email][3rd_email] , now the results from the sql above are to be the list of 1stemails.

I then want to search my table again and add the corresponding results to 2n_email positions in the array. And lastly with the 2nd_email results

i want to search table again and return the 3rd_emails.

 

Hope that helps. Anyone know how to convert my array into a multi-demensional array???

Link to comment
https://forums.phpfreaks.com/topic/188886-multi-dimensional-arrays-how-to-create/
Share on other sites

If you want to have, for example, your 3emails stored 2 levels down (1st => 2nd =>3rd) something like this might suffice.

$emails = array(
'emails_1' => array(
	'data' = array(),
	'emails_2' => array(
		'data' => array(),
		'emails_3' => array(
			'data'=>array()
		)
	)
)
);

then when you are getting the emails

// First
$emails['emails_1']['data'] = $fetched_rows1;
// Second
$emails['emails_1']['emails_2']['data'] = $fetched_rows2;
// Third
$emails['emails_1']['emails_2']['emails_3']['data'] = $fetched_rows3;

 

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.