|
Posted by Rik on 05/07/06 14:04
Alex Murphy wrote:
> The database is using text file to store the data. I using "list" and
> "split" function to split the "|" delimiter.
> This text file will upload to the server from the shop everydays.
OK, you don't use a database, only a textfile. Check:
http://nl3.php.net/manual/en/function.fgetcsv.php and the like
I'd say this should be database work, but hey, arrays work too, only with a
little bit more hassle.
It would be a lot of help if you would have mentioned HOW you create the
arrays, keys etc.
If you've made an array containing: index=>array(item, qty)
/* sum the different rows on item */
foreach($array as $row){
$totals[$row['item']] += $row['qty']
}
/* get max and min value */
$max = max($totals);
$min = min($totals);
/* We need an array_search_all, mark meves posted one on php.net */
function array_search_all($needle,$haystack){
return array_keys(array_filter($haystack, create_function('$s','return $s
== \''.addslashes($needle).'\';')));
}
/* get id's where the qty is max or min */
$max_items = array_search_all($max, $totals);
$min_items = array_search_all($in, $totals);
Is that what you want, or is my lack of detailed knowledge of the english
language causing me to do something completely different?
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|