array_search 関数について少し混乱しています (または、間違ったものを使おうとしているのかもしれません)。多数のトランザクション オブジェクト (顧客に関するトランザクション) があり、それぞれが値の配列です。電子メール アドレスを渡すと、その電子メール アドレスが使用された 1 つのトランザクションであるオブジェクトを取得します。例を以下に示します。コマンドから取得しますprint_r($results)
:
stdClass Object
(
[OverallStatus] => OK
[RequestID] => 4564564654-65465464565-4654654
[Results] => Array
(
[0] => stdClass Object
(
[thing1] =>
[thing2] =>
[Status] => Active
[ID] => 5555555555
[email_addy] => someaddy@something.com
)
[1] => stdClass Object
(
[thing1] =>
[thing2] =>
[Status] => Active
[ID] => 6666666666
[email_addy] => someaddy@something.com
)
[2] => stdClass Object
(
[thing1] =>
[thing2] =>
[Status] => Active
[ID] => 6666666666
[email_addy] => someaddy@something.com
)
)
)
この出力はまったく問題なく得られます。私の問題は、誰かが特定の ID を持っていることを特定する必要があることです。foreach を使用しようとしましたが、必要なものが返されません。コードと出力は以下のとおりです。
foreach ($results as $key => $value) {
echo "Key: $key; Value: $value<br />\n";
}
出力は
Key: OverallStatus; Value: OK
Key: RequestID; Value: 4564564654-65465464565-4654654
Key: Results; Value: Array
私が本当に知る必要があるのは、顧客の ID が かどうかだけです5555555555
。この数は常に同じままです。ここで間違った方向に進んでいますか?