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 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流