Re: need help with foreach()
| From: | David Rice | Date: | Mon, 10 Mar 2003 00:10:05 +0000 |
| Subject: | Re: need help with foreach() | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-26211@lists.php.net to get a copy of this message | ||
Hey thank's for the ideas but neither of them work, doh...
Okay fredrik I know your idea won't work cos list only works with numericaly indexed arrays, both the arrays that i am using are indexed by date.
(it produces a parse error when run)
=====================
while(list($d, $t) = each($tips)){
$res = $t / $staff[$d];
// Do what you need with $res ...
}
=====================
Janet your idea i would have thought would work.... but i can't get it to, for some reason
whenever I run the script it just gives me...
"Warning: Invalid argument supplied for foreach() in /home/filterseveuk/public_html/project/tips.php on line 56"
Not sure as to what it is talking abotu here as far as I know, this should work.
=====================
foreach($tips as $key => $value){
$pointvalue[$key] = $value / $staff[$key] ;
}====================== Does anyone else have a solution!? Cheers, Dave In a message dated 3/9/2003 2:07:26 PM Pacific Standard Time, haloplayer@hotmail.com writes: Okay, i have two arrays, $tips and $staff $tips has a key "date" (which is the date of the first day of the week, the second result in the array has the key of the second day of the week etc... ) and the value is a floating point decimal. $staff also has a key "date" and the value is an integer, the number of staff working in one day. To find out the ammount of tips every staff member is to get we have to divide the value of $tips by the value of $staff (when the dates are the same) what i was trying to get this to work is below, any help would be great, cheers dave ===================== foreach($tips as $key => $value){
$pointvalue[$key] = $value / current($staff) ;
next($staff); }_________________________________________________________________ It's fast, it's easy and it's free. Get MSN Messenger today! http://messenger.msn.co.uk