PHPでオブジェクトをソートするにはどうすればよいですか? 私は試しshuffle()
ましたが、それは配列を期待しています:
Warning: shuffle() expects parameter 1 to be array,
object given in /var/www/index.php on line 366
Warning: Invalid argument supplied for foreach() in /var/www/index.php on line 334
これは私のコードです:
public function updateStatusWithoutDB() {
$this->updateProfileColors();
$items = $this->getItems();
$items = shuffle($items);
if($this->updateStatusArray($items))
return true;
return false;
}
Avar_dump($items);
はこれを返します:
["180"]=>
object(stdClass)#203 (1) {
["status"]=>
string(130) "I was checking Microsoft's Visual Studio page just no…"
}