how do I go about sorting an array I have made for input in the smarty template so I do not have to make the sort in SQL.
Here is the code that makes declarations to place via smarty in the template
Code: Select all
$records = array();
while ($catresult !== false && $catrow = $catresult->FetchRow()) {
$project_id = $catrow['project_id'];
$pro_query = 'SELECT * FROM '.cms_db_prefix().'module_csrproject WHERE project_id = ?';
$pro_result = $db->Execute($pro_query,array($project_id));
while ($pro_result !== false && $pro_row = $pro_result->FetchRow()) {
$region_id = $pro_row['region_id'];
$project_order = $pro_row['order_id'];
$project_name = $pro_row['project_name'];
$project_facts = $pro_row['project_facts'];
$project_details = $pro_row['project_details'];
}
$record = new stdClass();
$record->id = $project_id;
$record->order = $project_order;
$record->region = $region_id;
$record->name = $project_name;
$record->facts = $project_facts;
$record->details = $project_details;
$records[] = $record;
}
I want the array I deliver to smarty to be sorted via a PHP or smarty sort function for arrays.
Can anyone help?