0
から特定のキーからすべての値を取得する:PHPは、私は、SOAP Webサービスからこのようなオブジェクトを取得し、配列+オブジェクト
object(stdClass)#2 (1) {
["tasks"]=>
array(3) {
[0]=>
object(stdClass)#3 (9) {
["externalId"]=>
string(0) ""
["name"]=>
string(10) "Customer A"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["subtasks"]=>
array(2) {
[0]=>
object(stdClass)#4 (9) {
["externalId"]=>
string(1) "2"
["name"]=>
string(5) "Job 1"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["subtasks"]=>
object(stdClass)#5 (9) {
["externalId"]=>
string(0) ""
["name"]=>
string(7) "Job 1.1"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["subtasks"]=>
array(2) {
[0]=>
object(stdClass)#6 (8) {
["externalId"]=>
string(0) ""
["name"]=>
string(9) "Job 1.1.1"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
[1]=>
object(stdClass)#7 (8) {
["externalId"]=>
string(0) ""
["name"]=>
string(9) "Job 1.1.2"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
}
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
[1]=>
object(stdClass)#8 (9) {
["externalId"]=>
string(0) ""
["name"]=>
string(5) "Job 2"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["subtasks"]=>
object(stdClass)#9 (8) {
["externalId"]=>
string(2) "55"
["name"]=>
string(7) "Job 2.1"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
}
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
[1]=>
object(stdClass)#10 (8) {
["externalId"]=>
string(3) "123"
["name"]=>
string(10) "Customer B"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
[2]=>
object(stdClass)#11 (9) {
["externalId"]=>
string(0) ""
["name"]=>
string(10) "Customer C"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["subtasks"]=>
object(stdClass)#12 (8) {
["externalId"]=>
string(3) "918"
["name"]=>
string(5) "Job 1"
["description"]=>
string(0) ""
["bookable"]=>
bool(true)
["billable"]=>
bool(true)
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
["customField1"]=>
string(0) ""
["customField2"]=>
string(0) ""
["customField3"]=>
string(0) ""
}
}
}
は、私は外部IDのすべての要素をチェックするだけ愚かな機能を必要としています。
if(["externalId"] != "")
{
echo "value found! ".["externalId"]."<br>";
}
私はarray_walk_recursive
を使用しようとしましたが、オブジェクトは配列とオブジェクトが混在しています。
["subtasks"]要素を比較... SOAP呼び出しでSOAP_SINGLE_ELEMENT_ARRAYSを試してみました。違いはありません。 「マジック」はありますか?私は解決策がかなりシンプルだと思うが、まだそれを得ることはない:-(
注意:再帰レベルの制限はありません - すべての["subtasks"]には["subtasks"]以上が含まれています