PHP:在多维阵列中删除选定的条目



例如,我的数组称为$ test,所有内部的子阵列都称为'link',

array(6) {
[0] = > array(3) {
 ["link"] = > string(56)
    "http://gdata.youtube.com/schemas/2007#user.subscriptions" ["href"] = > string(67)
    "http://gdata.youtube.com/feeds/api/users/test/subscriptions" ["countHint"] = > int(1)
}[link] = > array(3) {
    ["rel"] = > string(51)
    "http://gdata.youtube.com/schemas/2007#user.contacts" ["href"] = > string(62)
    "http://gdata.youtube.com/feeds/api/users/test/contacts" ["countHint"] = > int(0)
}[link] = > array(2) {
    ["rel"] = > string(48)
    "http://gdata.youtube.com/schemas/2007#user.inbox" ["href"] = > string(59)
    "http://gdata.youtube.com/feeds/api/users/test/inbox"
}[link] = > array(2) {
    ["rel"] = > string(52)
    "http://gdata.youtube.com/schemas/2007#user.playlists" ["href"] = > string(63)
    "http://gdata.youtube.com/feeds/api/users/test/playlists"
}[link] = > array(3) {
    ["rel"] = > string(50)
    "http://gdata.youtube.com/schemas/2007#user.uploads" ["href"] = > string(61)
    "http://gdata.youtube.com/feeds/api/users/test/uploads" ["countHint"] = > int(22)
}[link] = > array(2) {
    ["rel"] = > string(64)
    "http://gdata.youtube.com/schemas/2007#user.newsubscriptionvideos" ["href"] = > string(75)
    "http://gdata.youtube.com/feeds/api/users/test/newsubscriptionvideos"
}

}

我将如何获得具有["href"] = > string(61)"http://gdata.youtube.com/feeds/api/users/test/uploads"内容的子阵列"链接"。谢谢!

$search = 'http://gdata.youtube.com/feeds/api/users/test/uploads';
$match = null;
foreach ($linkArray as $link) {
     if ($link['href'] == $search) {
          $match = $link;
     }
}

我认为这样的事情会为您完成工作。$ linkarray是您发布的数组

相关内容

  • 没有找到相关文章

最新更新