duanping2809 2014-02-06 10:07
浏览 34

PHP:删除多维数组中的选定条目

for example I have this array called $test and all of the sub-arrays inside are called '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"
}

}

How will I get the sub-array 'link' that has the ["href"] = > string(61)"http://gdata.youtube.com/feeds/api/users/test/uploads" content. Thanks!

  • 写回答

1条回答 默认 最新

  • duanque19820925 2014-02-06 10:17
    关注
    $search = 'http://gdata.youtube.com/feeds/api/users/test/uploads';
    $match = null;
    foreach ($linkArray as $link) {
         if ($link['href'] == $search) {
              $match = $link;
         }
    }
    

    I think something like that will do the work for you. $linkArray is the array you posted

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度