
Originally Posted by
neomaven
I tried experimenting with the examply you gave Ren, but was unable to get it to work properly. I appreciate your input nevertheless, I feel like I am getting closer.
Hmm, did some testing with code below, seems fine here sorts in ascending order by bid. (Using PHP5.0.4 atleast)
Code:
function randItem()
{
$Item = array();
$Item['Title'] = '';
$Item['Url'] = '';
$Item['Uri'] = '';
$Item['Description'] = '';
$Item['Bid'] = (float)mt_rand(0, 100000);
$Item['Impression'] = '';
return $Item;
}
$ary1 = array();
$ary2 = array();
$ary3 = array();
$ary4 = array();
for($i = 0; $i < 10; ++$i)
{
$ary1[] = randItem();
$ary2[] = randItem();
$ary3[] = randItem();
$ary4[] = randItem();
}
$aryNew = array_merge($ary1, $ary2, $ary3, $ary4);
/* Comparision function for usort, comparing to items */
function compareBids($item1, $item2) { return $item1['Bid'] - $item2['Bid']; }
/* Sort */
usort($aryNew, 'compareBids');
var_dump($aryNew);
Bookmarks