PHP帮我解析数组

时间:2013-10-08 08:07:31

标签: php

Array (
    [items] => Array (
        [0] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwbkg0RkdLZ0lpbzA&export=download
            [title] => 08. Devil Fish Dumpling.mp3
        )
        [1] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwckVzMXFwNDJTN3c&export=download
            [title] => 06. electro peaceful.mp3
        )
        [2] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwQWVlSHRiRDV0RVU&export=download
            [title] => 02. FRIENDSHIP.mp3
        )
        [3] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwbURlQ3U2VUFuSWs&export=download
            [title] => 03. polygon.mp3
        )
        [4] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwLXVGM1dKV1BjUDA&export=download
            [title] => 10. HEAVENLY MOON.mp3
        )
        [5] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwSWo1N2NtR2FDTHc&export=download
            [title] => 13 Far east nightbird.mp3
        )
        [6] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwWUJMbXJ0V2JsanM&export=download
            [title] => 01 - Connect.mp3
        )
        [7] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwQ0lVYndpRXlpRnM&export=download
            [title] => 02 Don\\\'t cry.mp3
        )
        [8] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwMVl3WHRVenB4akE&export=download
            [title] => 01 nexus.mp3
        )
        [9] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwZVdmQnBXX1pnTEE&export=download
            [title] => 1-02 SEED.mp3
        )
        [10] => Array (
            [webContentLink] => https://docs.google.com/uc?id=0B-8ZjfWGsMOwNTZHTHV4TjYzZHM&export=download
            [title] => 1-01 Follow me.mp3
        )
    )
)

我需要解析这个数组。

1 个答案:

答案 0 :(得分:0)

$links = array();
$titles = array();
foreach ($arr['items'] as $key => $item)
{
$links[$key] = $item['webContentLink'];
$titles[$key] = $item['title'];
}
for ($counter=0; $counter<count($links);$counter++)
{
echo 'The song has link: '.$links[$counter].'<br />Title: '.$titles[$counter];
}

阵列链接标题将包含您需要的所有信息。