0
In the framework I develop (PHP language), I use multidimensional array for HTML reporting.
There is a particular report that I cannot properly sort in the SQL query, having only all the data by which I wish to sort after array formation.
Example of the array:
$dados[] = array(
$cont++,"<nobr>".$nome."</nobr>",
"<div align=\"center\">".$this->tipoCliente($r['taxa'])."</div>",
$this->converte_mes($this->mesSel),
"<div align=\"right\">".number_format($r['taxa'], 2, ',', '.')."</div>",
"<div align=\"right\">".number_format($taxa, 2, ',', '.')."</div>",
"<div align=\"right\">".number_format($dife, 2, ",", ".")."</div>",
$chk
);
I even managed to reorder the array using the following function:
foreach ($dados as $key => $row)
{
$tipo[$key] = $row[2];
$val[$key] = $this->dinheiroInteiro($row[3]);
}
array_multisort($tipo, SORT_ASC, $val, SORT_DESC, $dados);
But I still have some problems with the values, and I would need to reset the counter so that it would be starting from 1 after reordering the array.
Just to explain better then, after using the multisort array_array, I reorder the array by the type of client (A, B, C, D)... and the tiebreaker criterion was 4 column (rate). But after my reordering through Multisort the sequence is lost (because the initial ordering of the dice played through while is undone), because it was done by the name.
Any suggestions?
Okay, it’s not exactly clear what you’re up to, but at least I can make a guess. Would you like to renumber array indexes back to "normal" (0,1,2,3...)? If so, just pass the array by array_values()
– Bruno Augusto