aidal
Maybe the array_walk() function is for you - but in general terms it is
perhaps better to have a crack at a clever SQL statement if you are pulling
stuff out of a database in any case.   Look at nested SELECT statements and
the MAX() function.  Or, if not that, creating a temporary table with a
SELECT astatement then applying a second SELECT to that table???



----- Original Message -----
From: "Aidal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 16, 2002 10:59 PM
Subject: [PHP-WIN] Arrays - I may have gone blind


> Hi NG.
>
> I'm sure there is somthing implemented in PHP to do this but I just cant
see
> it.
>
> I want to run through an array and remove some entries where <somthing 1>
is
> true and <somthing 2> is lower than the other entries of <somthing 1>
>
> First i thought... hmm this sounds like a linked list, I'm gonna make one.
> But I cant seem to make the list concept work properly with PHP, so I
> thought that somthing might have been made for this.
>
> Example:
>
> for ($i = 0; $i < sizeof(some_db_result); $i++) {
>     array[$i]['id'] = this_db_result_row['id'];
>     array[$i]['type']  = this_db_result_row['type'];
>     array[$i]['v_id'] = this_db_result_row['v_id'];
> }
> // (id) is unique
> // (type) is 1-4
> // (v_id) is not unique.
>
> What I want to do is to find all entries where (v_id) is the same and then
> remove all but the one where (type) has the highest value.
> How do I do this?
> Or can a SQL statement do this in a DISTINCT like way? (SELECT table.id
FROM
> table WHERE somthing is = somthing else and a lot of other stuff BUT only
> give me those where table.type has the hifgrst value)?
>
> Please... need help with this
> ~ Aidal.
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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

Reply via email to