Need Help on Sorting Arrays..

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

 



Thanks a lot heilo...

I'll try this one out.


------------------------------------------------- hm......


Seems as if it was really impossible to make this with the query. (Unless one would change the dbmodel so that the connections get easier)

Well to solve your array-problem use array_multisort:

   $supplier = array(    'FTSL1'
                   ,    'FTSL1'
                   ,    'FTSL2'
                   ,    'FTSL2'
                   ,    'FTSL2'
                   ,    'MIC'
                   ,    'MIC'
                   ,    'MIC'
                   ,    'MIC'
                   ,    'MIC'
                   ,    'MIC'
                   );
   $partCode = array(    '954334-02310730'
                   ,    '9445R0-05200730'
                   ,    '324941-06100900'
                   ,    '324941-06200900'
                   ,    '324941-0570A900'
                   ,    '981028-03570730'
                   ,    '811600-41650730'
                   ,    '811600-41050730'
                   ,    '811600-31700740'
                   ,    '954105-03050730'
                   ,    '934100-03650730'
                   );
   $partName = array(    'Ceramic Condenser'
                   ,    'Ceramic Condenser'
                   ,    'Chemical Condenser'
                   ,    'Chemical Condenser'
                   ,    'Ceramic Condenser'
                   ,    'Connector'
                   ,    'IC'
                   ,    'IC'
                   ,    'IC'
                   ,    'Ceramic Condesner'
                   ,    'Capacitor'
                   );
   $partQty = array(    0
                   ,    0
                   ,    100
                   ,    0
                   ,    300
                   ,    3000
                   ,    2000
                   ,    19000
                   ,    2500
                   ,    12000
                   ,    2000
                   );
   $soQty = array(    7890
               ,    10800
               ,    3300
               ,    4700
               ,    500
               ,    3000
               ,    654
               ,    18162
               ,    654
               ,    11166
               ,    546
               );

   $numbers = array(    '2nd'
                   ,    '1st'
                   ,    '4th'
                   ,    '5th'
                   ,    '3rd'
                   ,    '8th'
                   ,    '11th'
                   ,    '10th'
                   ,    '9th'
                   ,    '7th'
                   ,    '6th'
                   );

   $ar = array(     'supplier'    =>    $supplier
               ,    'partName'    =>    $partName
               ,    'partCode'    =>    $partCode
               ,    'partQty'     =>    $partQty
               ,    'soQty'       =>    $soQty
               ,    'numbers'     =>    $numbers
               );

   // echo the 2d-array
   $cMax = count($ar['supplier']);
   for($c = 0; $c < $cMax; $c++)
       echo    $ar['supplier'][$c].' | '.
               $ar['partName'][$c].' | '.
               $ar['partCode'][$c].' | '.
               $ar['partQty'][$c].' | '.
               $ar['soQty'][$c].' | '.
               $ar['numbers'][$c].
               '<br>'."\n";

   // sort it
   array_multisort($ar['supplier'], SORT_ASC, SORT_STRING
               ,    $ar['partName'], SORT_ASC, SORT_STRING
               ,    $ar['partCode'], SORT_ASC, SORT_STRING
               ,    $ar['partQty']
               ,    $ar['soQty']
               ,    $ar['numbers']
               );
   echo '<br><br>';

   // echo the 2d-array
   $cMax = count($ar['supplier']);
   for($c = 0; $c < $cMax; $c++)
       echo    $ar['supplier'][$c].' | '.
               $ar['partName'][$c].' | '.
               $ar['partCode'][$c].' | '.
               $ar['partQty'][$c].' | '.
               $ar['soQty'][$c].' | '.
               $ar['numbers'][$c].
               '<br>'."\n";


hope this works, and helps?!


.ma

------------------------------------------


Marie Gezeala M. Bacuño II Information Systems Department

Your choice: the red pill or the blue pill.

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail



-- 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