mardi 29 mars 2016

PHP - Sqlite - sort data with usort

I m trying to sort some data retrieved from a 'sqlite table' with usort, and I receive error "expects parameter 1 to be array" .

$result = $db->query('SELECT * FROM users'); // retrieve data
usort($result, 
    function($a, $b) { 
        return $a["BUY"] - $b["BUY"]; 
    }
);

This is just part of the code. I can read the data well, just can't sort it.

Aucun commentaire:

Enregistrer un commentaire