php uasort w 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;
}
}
Otrzymuję następujące ostrzeżenie:
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.
A 554. linia zawierauasort($posts_array, $this->cmp)
.
Gdzie korzystać z ciągu lub tablicy iw jaki sposób?
EDYTOWAĆ : Jeśli używamuasort($posts_array, array($this, 'cmp'));
, Otrzymuję następujące ostrzeżenie:
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