foreach ループ中に配列の配列を作成しました (と思います)。
$collectGroup = array();
foreach ($topTenList->searchResult->item as $group) {
$collectGroup['title'] = $group->title;
$collectGroup['price'] = $group->sellingStatus->convertedCurrentPrice;
$collectGroup['image'] = $group->galleryURL;
$collectGroup['url'] = $group->viewItemURL;
}
配列出力の Var ダンプ:
array(4) {
["title"]=>
object(SimpleXMLElement)#13 (1) {
[0]=>
string(74) "title 1"
}
["price"]=>
object(SimpleXMLElement)#16 (2) {
["@attributes"]=>
array(1) {
["currencyId"]=>
string(3) "GBP"
}
[0]=>
string(9) "1500000.0"
}
["image"]=>
object(SimpleXMLElement)#14 (1) {
[0]=>
string(63) "http://www.website.com/image1.jpg"
}
["url"]=>
object(SimpleXMLElement)#15 (1) {
[0]=>
string(140) "http://www.website.com"
}
}
array(4) {
["title"]=>
object(SimpleXMLElement)#11 (1) {
[0]=>
string(80) "title 2"
}
["price"]=>
object(SimpleXMLElement)#12 (2) {
["@attributes"]=>
array(1) {
["currencyId"]=>
string(3) "GBP"
}
[0]=>
string(9) "8000088.0"
}
["image"]=>
object(SimpleXMLElement)#17 (1) {
[0]=>
string(63) "http://www.website.com/image2.jpg"
}
["url"]=>
object(SimpleXMLElement)#16 (1) {
[0]=>
string(140) "http://www.website.com"
}
}
私が今やりたいことは、配列内の配列を価格の降順に並べることです。したがって、この例では、価格が 1500000.0 のアレイの上に、価格が 8000088.0 のアレイが必要です。私が試してみました:
ksort($collectGroup['price'], SORT_NUMERIC);
しかし、運が悪い、助けてください