我有以下对象:
object(oxVariantSelectList)[18927]
protected '_sLabel' => string 'Größe' (length=7)
protected '_iIndex' => int 1
protected '_aList' =>
array (size=5)
'02ce605576fee3181f11ebd2c87baed0' =>
object(oxSelection)[18965]
protected '_sName' => string 'Benny' (length=5)
protected '_sValue' => string '02ce605576fee3181f11ebd2c87baed0' (length=32)
protected '_blActive' => boolean false
protected '_blDisabled' => null
'690645228c86f17648b3a7b1286f1946' =>
object(oxSelection)[18968]
protected '_sName' => string 'Arvid' (length=5)
protected '_sValue' => string '690645228c86f17648b3a7b1286f1946' (length=32)
protected '_blActive' => boolean false
protected '_blDisabled' => null
'972b08df7f6a1a19405f28c1e984b115' =>
object(oxSelection)[18969]
protected '_sName' => string 'Chris' (length=5)
protected '_sValue' => string '972b08df7f6a1a19405f28c1e984b115' (length=32)
protected '_blActive' => boolean false
protected '_blDisabled' => null
'1ba5f38fd6213a22679a4eba30651390' =>
object(oxSelection)[18970]
protected '_sName' => string 'Alex' (length=5)
protected '_sValue' => string '1ba5f38fd6213a22679a4eba30651390' (length=32)
protected '_blActive' => boolean false
protected '_blDisabled' => null
'b0a471b33a911ce8fed459d607f0ffb3' =>
object(oxSelection)[18985]
protected '_sName' => string 'Mona' (length=5)
protected '_sValue' => string 'b0a471b33a911ce8fed459d607f0ffb3' (length=32)
protected '_blActive' => boolean false
protected '_blDisabled' => null
protected '_oActiveSelection' => null
我想按_sName ($obj->getName())
对数组进行排序。
有什么方法可以通过php实现这个目标吗?
eidt:我因为一些混乱而改变了_sName:)
提前致谢。
答案 0 :(得分:0)
您可以使用usort对其进行排序,
usort($array, function($a, $b){return intval($a->_sName) - intval($b->_sName);}
答案 1 :(得分:0)
您可以使用usort
:
uasort($obj->_aList, function($a, $b) { return strcmp($a->_sName, $b->_sName) });