我想表演一个 usort
usort
class foo { private $array; private $key; private $dir; function sort() { usort($this->array, array("foo", "orderArray")); } function orderArray($a, $b) { return strcmp($a[$this->key], $b[$this->key]) * $this->dir; } }
orderArray 同学们,你们 无法访问$key或$dir . 问题是, 我该怎么写才能写呢?
orderArray
看起来您只是想查看当前实例?把它传给我。
function sort() { usort($this->array, array($this, "orderArray")); }