将Wikipedia API搜索结果排序为数组[关闭]

Using the following code as an example:

$wikisearch = "http://en.wikipedia.org/w/api.php?action=opensearch&search=inception";
$wikisearchlist = file_get_contents($wikisearch);
echo $wikisearchlist;

I get this:

[
    "inception",
    [
        "Inception",
        "Inception Motorsports",
        "Inception of Darwin's theory",
        "Inception (soundtrack)",
        "Inception (McCoy Tyner album)",
        "Inception (Download album)",
        "Inception/Nostalgia",
        "Inception date",
        "Inception (disambiguation)"
    ]
]

I want to firstly remove the query at the start ("inception"), then decode the JSON to create an array of all the results. Then, remove the array elements that don't contain '(soundtrack)' and '(Download album)' in them (except the first result), so the final array would look something like:

[0] => "Inception"
[1] => "Inception (soundtrack)"
[2] => "Inception (Download album)"

What's the best way to do this? Thanks

Decode the JSON

$json = json_decode($wikisearchlist);
$results = $json[1];

Filter the array

$first = array_shift($results);

$filtered = array_filter($results, function($result) {
    return strpos($result, '(soundtrack)') !== false
        || strpos($result, '(Download album)') !== false;
});

array_unshift($filtered, $first);

Demo here - http://codepad.viper-7.com/siX4aY