doujiu8178 2017-04-05 03:41
浏览 42
已采纳

返回除数组php中的特定键以外的所有内容

Let's say i have an array below, I want to return everything except [year] key. How can i do that in php? Sorry if this is a newbie question.

 Array
        (
            [0] => Array
                (
                    [filmId] => 61359
                    [url] => http://www.moviemeter.nl/film/61359
                    [title] => Unstoppable
                    [alternative_title] => 
                    [year] => 2011
                    [thumbnail] => http://www.moviemeter.nl/images/covers/thumbs/61000/61359.jpg
                    [average] => 0
                    [votes_count] => 0
                    [similarity] => 100.00
                    [directors_text] => geregisseerd door Richard Harrison
                    [actors_text] => met Chen Shilony, Ruben Crow en David Powell
                    [genres_text] => Drama / Komedie
                    [duration] => 90
                )
            [1] => Array
                (
                    [filmId] => 87923
                    [url] => http://www.moviemeter.nl/film/87923
                    [title] => Unstoppable
                    [alternative_title] => 
                    [year] => 2011
                    [thumbnail] => http://www.moviemeter.nl/images/covers/thumbs/87000/87923.jpg
                    [average] => 0
                    [votes_count] => 0
                    [similarity] => 100.00
                    [directors_text] => geregisseerd door Example Director
                    [actors_text] => met Actor 1, Actor 2 en Actor 3
                    [genres_text] => Drama / Komedie
                    [duration] => 90
                )
            [2] => Array
                (
                    [filmId] => 68593
                    [url] => http://www.moviemeter.nl/film/68593
                    [title] => Unstoppable
                    [alternative_title] => 
                    [year] => 2010
                    [thumbnail] => http://www.moviemeter.nl/images/covers/thumbs/68000/68593.jpg
                    [average] => 3.3
                    [votes_count] => 191
                    [similarity] => 100.00
                    [directors_text] => geregisseerd door Tony Scott
                    [actors_text] => met Denzel Washington, Chris Pine en Rosario Dawson
                    [genres_text] => Actie / Thriller
                    [duration] => 98
                )
            [3] => Array
                (
                    [filmId] => 17931
                    [url] => http://www.moviemeter.nl/film/17931
                    [title] => Unstoppable
                    [alternative_title] => Nine Lives
                    [year] => 2004
                    [thumbnail] => http://www.moviemeter.nl/images/covers/thumbs/17000/17931.jpg
                    [average] => 2.64
                    [votes_count] => 237
                    [similarity] => 100.00
                    [directors_text] => geregisseerd door David Carson
                    [actors_text] => met Wesley Snipes, Jacqueline Obradors en Mark Sheppard
                    [genres_text] => Actie / Thriller
                    [duration] => 96
                )
        )

Sorry if this is a newbie question. Please help me out as i dont know if this is possible or not. thank you.

  • 写回答

1条回答 默认 最新

  • dra11767 2017-04-05 03:45
    关注
    function remove_year_key(&$films) {
        foreach ($films as &$film) {
            unset($film["year"])
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理