[ciapug] Multi-dimensional array

Lathrop Preston ciapug@cialug.org
Mon, 17 Nov 2003 12:12:44 -0600


No problem. I do that sort of thing way more often than you might think 
would be needed...

Lathrop

Chris Hettinger wrote:

> Thanks guys,
> 
> Laith, your example was right on with the way I had started to go, so that's cool, I wasn't as far off as I thought I was.
> 
> -ch
> 
> -----Original Message-----
> From: Lathrop Preston [mailto:laith@prestonfam.org]
> Sent: Monday, November 17, 2003 11:36 AM
> To: ciapug@cialug.org
> Subject: Re: [ciapug] Multi-dimensional array
> 
> 
> Mixed pseudo/real code
> 
> LOOP FOR RECSET
> 	IF TEST PASS
> 		$passed_array[] = array( "ssn" => RECSET(ssn), "dob" => RECSET(dob), 
> "joined" => RECSET(joined));
> 
> END LOOP
> 
> to count records just do
> 	$rec_count = count($passed_array);
> 
> the resultant array will be like this
> 
> array(
> 	0 => array("ssn" => ######, "dob" => ####/##/##, "joined" => ####/##/##)
> )
> 
> to address any given element
> 
> $datum = $passed_array[$row][$field];
> 
> so to get the third ssn in the set
> $ssn = $passed_array[2]["ssn"];
> 
> Lathrop
> 
> Chris Hettinger wrote:
> 
> 
>>As I loop through a result set I test each row, and for each row that passes, I need to record the information from 3 of the fields in the result set. Once I reach the end of my result set I need to look at the array of information, and count the number of records that had matched. Then I have a additional test I can run if I have more than one 1 row in my array. The goal is to find a 'single' match within a set of information that can in many cases have multiple results that can contain nearly exact information... Think, medical information where the only difference at times is the date on a policy, either it's active or not... or multiple policies for an individual...much of the information I have can be the same.
>>
>>To do this I believe I need to use a multi-dimensional array, but I am not sure how to go about implementing this. My knowledge of arrays is low, and the doc's I have read haven't cleared this up for me.
>>
>>For an example say the fields are
>>1) SSN
>>2) Birth date
>>3) Date Joined
>>
>>So say I have 3 records pass my tests I need to record
>>	
>>ssn                dob              joined
>>111-11-1111   1990-03-05    2003-01-01
>>222-22-2222   1990-03-05    2001-03-07
>>333-33-3333   1990-03-05    1987-12-23
>>
>>When I count the array, I need to know I have 3 records.
>>
>>What I am hoping for here, is a example of how to create this array, and how to properly index it so I can count the rows properly.
>>
>>
>>
>>-Chris Hettinger, Web Specialist
>>-IFMC/ENCOMPASS
>>-www.encompas.com
>>-(515) 279-8730
>>
>>
>>
>>CONFIDENTIALITY NOTICE:  This communication, including any attachment, may contain confidential information and is intended only for the individual or entity to whom it is addressed.  Any review, dissemination, or copying of this communication by anyone other than the intended recipient is strictly prohibited.  If you are not the intended recipient, please contact the sender by reply email, delete and destroy all copies of the original message.'
>>
>>_______________________________________________
>>ciapug mailing list
>>ciapug@cialug.org
>>http://cialug.org/mailman/listinfo/ciapug
> 
> 
> 
> _______________________________________________
> ciapug mailing list
> ciapug@cialug.org
> http://cialug.org/mailman/listinfo/ciapug
> 
> 
> CONFIDENTIALITY NOTICE:  This communication, including any attachment, may contain confidential information and is intended only for the individual or entity to whom it is addressed.  Any review, dissemination, or copying of this communication by anyone other than the intended recipient is strictly prohibited.  If you are not the intended recipient, please contact the sender by reply email, delete and destroy all copies of the original message.'
> 
> _______________________________________________
> ciapug mailing list
> ciapug@cialug.org
> http://cialug.org/mailman/listinfo/ciapug