stolzyboy wrote:<?php
function cmp($a, $b)
{
return strcasecmp($a, $b);
}
$array = array(); // initialize array
//lines 10-12 will be done during each "loop"
$array['key1'] = "value1";
$array['key2'] = "value2";
$array['key3'] = "value3";
uksort($array, "cmp");
foreach($array as $company => $miles){
echo $company . " - " . $miles . "<br>";
}
?>
//this will print
key1 - value1
key2 - value2
key3 - value3
i have it sorting by "key" so you can ignore the uksort and the function if you wish
cheers mate, but i was pooling data from a database query then filtering it through a custom made function (findsout the difference in weeks)
if the weeks returned showed a difference of 2 weeks between todays date, and when an entry was made, i want the assoc array to store the month name with a value "old"
if the week difference is under 2 then the value is "new"
i managed to fix it. Im sooo stupid!
if($diff<2){
$month_name = $row[0];
$month_status[$month_name] = 'new';
}
else{
$month_name = $row[0];
$month_status[$month_name] = 'old';
}
sorry about the poor explanation!