dongxifu5009 2012-11-01 22:59
浏览 126
已采纳

从foreach PHP上的数组中删除值

I have an array like this:

    Array
(
    [0] => Array
        (
            [id] => 68
            [type] => onetype
            [type_id] => 131
            [name] => name1
        )

    [1] => Array
        (
            [id] => 32
            [type] => anothertype
            [type_id] => 101
            [name] => name2
        )
)

I need to remove some arrays from it if the users has permissions or not to see that kind of type. I am thinking on doing it with a for each, and do the needed ifs inside it to remove or let it as it.

My question is: What's the most efficent way to do this? The array will have no more than 100 records. But several users will request it and do the filtering over and over.

  • 写回答

3条回答 默认 最新

  • douhui2307 2012-11-02 10:27
    关注

    use this 1 simple and easy

    foreach ($display_related_tags as $key => $tag_name) {
        if($tag_name == $found_tag['name']) {
           unset($display_related_tags[$key]);
         }
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制