0

I am using array_diff to remove an item from an array... It works at removing 'field_home_slider', but the final print render() is outputting like 15 times. Am I missing something as to why the print would do that?

Can this be written a cleaner way? I want item 'field_home_slider' removed from $page['content'];

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

Original code

print render($page['content']); 
2
  • Dear acctman , Can you add which data contains in $page['content'] and its out put ? Commented Dec 3, 2015 at 13:44
  • @ShreyPrajapati $page['content'] out puts all the content without anything being removed. I am using array_diff to filter it and remove item "field_home_slider". now when i out put $array_remove it is reprinting everything multiple times instead of just once. Commented Dec 3, 2015 at 14:01

1 Answer 1

1

You could try this:

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

Here is the reference to the hide() function: https://api.drupal.org/api/drupal/includes!common.inc/function/hide/7

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.