Re: need help with foreach()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux