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 = 'kieron@webdesign4u.ie'";
	$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
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;

 

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.