使用array_diff删除项目


Using array_diff to remove an item

我正在使用array_diff从数组中删除项。。。它可以去除'field_home_slider',但最终的print render()输出大约15次。我是不是遗漏了print为什么会这么做?

这能写得更干净吗?我希望从$page中删除项目'field_home_slider'["内容"];

$array_remove = array_diff($page['content'], array('field_home_slider'));
print render($array_remove);

原始代码

print render($page['content']); 

你可以试试这个:

hide($page['content']['field_home_slider']);
print render($page['content']);

以下是对hide()函数的引用:https://api.drupal.org/api/drupal/includes!common.inc/function/hide/7