我在php数组中存储了一个查询结果
Array
(
[0] => stdClass Object
(
[AccountNumber] => 1000000
[FirstName] => james
[LastName] => James Administrator
)
[1] => stdClass Object
(
[AccountNumber] => 1000001
[FirstName] => george
[LastName] => James
)
[2] => stdClass Object
(
[AccountNumber] => 1000002
[FirstName] => Clara
[LastName] => Pradeep
)
[3] => stdClass Object
(
[AccountNumber] => 1000003
[FirstName] => Dona
[LastName] => Kodi
)
)
我需要为特定的AccountNumber打印FirstName和LastName
FirstName:Clara
姓氏:Pradeep
其中AccountNumber为1000002
提前致谢
答案 0 :(得分:0)
在数组中搜索您想要的帐号,然后输出:
$object_array = {your array}; // whatever variable you have to print out what you posted
foreach ($object_array as $account) {
if ($account->AccountNumber == "1000002") { // change the number to a variable if required
echo "<p>FirstName: " . $account->FirstName . "</p>";
echo "<p>:LastName: " . $account->LastName . "</p>";
}
}