在PHP查询结果中查找对象
我正在从Joomla 2.5中的自定义类别表加载值。这很好,我可以显示每个类别的名称 然后我想将具有特定id的类别添加到新数组中,但我无法使其正常工作。 在C#中,我确切地知道如何做到这一点,但在PHP中却不知道 以下是我的代码(thx用于修复代码格式):在PHP查询结果中查找对象,php,joomla2.5,Php,Joomla2.5,我正在从Joomla 2.5中的自定义类别表加载值。这很好,我可以显示每个类别的名称 然后我想将具有特定id的类别添加到新数组中,但我无法使其正常工作。 在C#中,我确切地知道如何做到这一点,但在PHP中却不知道 以下是我的代码(thx用于修复代码格式): 根据joomla loadObjectList()返回如下数组: Array ( [0] => stdClass Object ( [id] => 1 [name] => John Smith [ema
根据joomla loadObjectList()返回如下数组:
Array (
[0] => stdClass Object ( [id] => 1 [name] => John Smith
[email] => johnsmith@domain.example [username] => johnsmith )
[1] => stdClass Object ( [id] => 2 [name] => Magda Hellman
[email] => magda_h@domain.example [username] => magdah )
[2] => stdClass Object ( [id] => 3 [name] => Yvonne de Gaulle
[email] => ydg@domain.example [username] => ydegaulle )
)
那么试试
$cat->id
(小写字母I)有什么问题<代码>$arr2是否仍为空?尝试了$cat->id
(小写字母I)?在旁注中,您应该使用#uuu
来定义表前缀,而不是ind_u
,因此它将是$query->from(“#uu类别”)代码>
Array (
[0] => stdClass Object ( [id] => 1 [name] => John Smith
[email] => johnsmith@domain.example [username] => johnsmith )
[1] => stdClass Object ( [id] => 2 [name] => Magda Hellman
[email] => magda_h@domain.example [username] => magdah )
[2] => stdClass Object ( [id] => 3 [name] => Yvonne de Gaulle
[email] => ydg@domain.example [username] => ydegaulle )
)