Hi

> -----Original Message-----
> From: Barry [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, March 27, 2001 10:23 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Array How To ???
> 
> 
> Hello Everyone,
> 
> I would like to sort a list of array indices. The array is 
> multi- dimensional N x 3
> 
> for example, if (note the actual data is not important to my 
> question):
> 
> $a[0]['a'] = 1, $a[0]['b'] = 2, $a[0]['c'] = 3
> $a[1]['a'] = 1, $a[1]['b'] = 2, $a[1]['c'] = 3
> $a[2]['a'] = 1, $a[2]['b'] = 2, $a[2]['c'] = 3
> 
> Q1) I will use the "usort" user sort function. I see the 
> example for multi-dimensional arrays in the manual (they use 
> fruits, not a b c). Does usort work in Windows (NT4 machine, 
> PHP 4.04, running as cgi) ?

yes, used it some time ago ;)

> 
> Q2) The array $a will be stored in a session. I will want to 
> clear $a and then  recreate and resort $a. How do I clear a 
> variable or array ?

easiest way:
unset($a);

or for a specific item

unset($a[1]);

> For example, if the first time I create $a it gets up to 
> $a[30] (remember $a is saved in a session), but if I recreate 
> $a and the indices only go to $a[20], I need to be sure 
> $a[21] to $a[30] no longer exist. Easiest way: clear $a 
> before recreating it.
> 
> Q3) The $a array will be generated from the results of a 
> mysql database query. Is it realistic to save the results set 
> ($res) of a query ($res =
> mysql_query($sql)) in a session? I think the size of $res 
> won't exceed 32KB. Is there a session storage size limit for Windows?

hmm .. i don't know, but do not store the $res ... read the query line
by line into an array:

// Read the whole query and put it into a 2D Array
@unset($storearray);
while($row=mysql_fetch_array($res,MYSQL_ASSOC))
{
        $storearray[]=$row;
}

then put the storearray into your session ;)

> Thanks very much for your experience,
> Barry.

hope this helps ;)

CodeDuck

> 
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: 
> [EMAIL PROTECTED] To contact the list 
> administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to