Avatar of Matthew Roessner
Matthew Roessner

asked on 

PHP - Sort Multi-Dimensional Array

I have the following array, that I create within a "while loop":

$drugs[$totalcount]['drug']=$drug;
$drugs[$totalcount]['ndc']=$ndc;
$drugs[$totalcount]['prevcost']=$prevcost;
$drugs[$totalcount]['newcost']=$newcost;
$drugs[$totalcount]['drugcount']=$drugcount;
$drugs[$totalcount]['pc']=$pc;
$drugs[$totalcount]['dcv']=$dcv;

$totalcount=$totalcount+1;

I want to sort the $drugs array based on the "dcv" portion of the array.  I plan to output the array using a "for loop" - and want to have the output which I am using for a report - to list everything starting with the smallest DCV to the largest DCV.

I was looking at trying to use USORT() - but wasn't sure if that was the right direction or not.

Any help would be very much appreciated.

Thanks
PHP

Avatar of undefined
Last Comment
Matthew Roessner

8/22/2022 - Mon