php uasort in OOP
class DBNews {
public function get_latest_posts($limit){
// code goes here
$posts_array = array();
uasort($posts_array, $this->cmp);
}
public function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
}
Ich erhalte folgende Warnung:
Warning: uasort() expects parameter 2 to be a valid callback,
no array or string given in
C:\xampp\htdocs\news\admin\functions.php on line 554.
Und die 554. Zeile enthältuasort($posts_array, $this->cmp)
.
Wo und auf welche Weise kann der String oder das Array verwendet werden?
BEARBEITEN : Wenn ich benutzeuasort($posts_array, array($this, 'cmp'));
Ich bekomme folgende Warnung:
uasort() expects parameter 2 to be a valid callback,
array must have exactly two members in
C:\xampp\htdocs\news\admin\functions.php on line 554