Bonjour,

J ai deux tableaux Mysql j'essaye des le trier par date mais je galère un peu.
l erreur est que mon tableau n est pas considéré comme un tableau, alors il dit ceci:

Warning: usort() [function.usort]: The argument should be an array
------------------------------------------------------------

actuellement je teste donc differente synthaxe pour
$tableau_cree_utilise .= array($avoir_cree[$i],$date_cree[$i]);

apres je verrais pour le tri

toute aide est la bienvenue.
merci à tous
et bonne soirée

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
$tableau_cree_utilise = array();
$avoir_cree = array();
$date_cree = array();
$avoir_utilisee = array();
$date_utilise = array();
$total=0;
$i=0;
$i2=0;
 
//affiche les avoirs crees
$avoir_query = tep_db_query( "SELECT * FROM `customers_balance_history` WHERE customers_id=".(int)$cID." order by date_customers_balance DESC LIMIT 0,100");	
while ($avoir = tep_db_fetch_array($avoir_query)) {
$i++;
									$avoir_cree[$i]=number_format($avoir['amount_customer_balance'],2, ',', ' ');
									$date_cree[$i]= tep_date_short($avoir['date_customers_balance']);
									$tableau_cree_utilise .= array($avoir_cree[$i],$date_cree[$i]);
}
 
//fin affiche avoir cree/
//avoir utilisé
$customers_cli_query = tep_db_query( "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name,ot.class,ot.title, ot.text , ot.value as value_tot from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "'  order by date_purchased DESC");
while ($customers_cli = tep_db_fetch_array($customers_cli_query)) {
$i2++;
								if(($customers_cli['class']=='ot_account_balance')&&($customers_cli['title']=='<br>Total des avoirs disponibles TTC :')){
 
									$date_utilise=tep_date_short($customers_cli['date_purchased']);
									$text = str_replace('&euro;','',$customers_cli['text']);
									$text = str_replace('<br>','',$text);
									 $avoir_utilise[$i2]=number_format($text,2, ',', ' ');
									 $tableau_cree_utilise .= array($avoir_utilise[$i2],$date_utilise[$i2]);
 
								}//end if
}//fin while commande avoir utilisé
 
 
// trier fonction
function compare($a,$b)
{return strcmp($a["date"],$b["date"]);}
 
usort($tableau_cree_utilise,compare);
 
// output results
for($x = 0; $x < count($tableau_cree_utilise); $x++)
{
    //test affiche tableau cree et utilisee trié
	echo $tableau_cree_utilise[$x]."<br>";
	 //test affiche tableau cree et utilisee
	echo'<br><hr>';
	print_r ($tableau_cree_utilise[$x])."<br>";
}