我正在尝试按字母顺序对汽车名称列表进行排序。该列表基于排序方式不同的 JSON 源。汽车名称嵌套在源的更深层次中。这是我现在没有排序的内容:
<?php
$response = file_get_contents( 'http://api.autoit.dk/car/GetCarsExtended/391B093F-BB4A-45AA-BEFF-7B33842401EA' );
$myArray = json_decode($response, true);
foreach($myArray as $item):
echo $item['FabrikatNavn'].' '.$item['ModelNavn'].' '.$item['VariantBetegnelse'];
?>
有人对如何使汽车名称列表按字母顺序显示有建议吗?如您所见,提要来自以下网址:http://api.autoit.dk/car/GetCarsExtended/391B093F-BB4A-45AA-BEFF-7B33842401EA
我想按其排序的汽车名称嵌套在提要中,如下所示:经销商CarExtended --> FabrikatNavn
您可以使用
sort($myArray)
函数。
在这里查看: http://php.net/manual/en/function.sort.php