2

I am experiencing a weird error from an array_diff statement. The statement is:

$query = array_diff($params, array('f' => array()));

and the var_dump of the $params is array(1) { ["f"]=> array(0) { } }

This happens in a drupal module called Islandora_solr_search and I get the following error message twice like below

Notice: Array to string conversion in IslandoraSolrResults->setBreadcrumbs() (line 427 of /var/www/drupal/sites/all/modules/islandora_solr_search/includes/results.inc).

Notice: Array to string conversion in IslandoraSolrResults->setBreadcrumbs() (line 427 of /var/www/drupal/sites/all/modules/islandora_solr_search/includes/results.inc).

Does anyone know why this happens?

0

1 Answer 1

4

array_diff throws notice errors when it finds an array inside an array. See the comment by Michiel Thalen

I may assume that you're running php 5.4 or higher. You can see it by yourself, by checking your array_diff statement in the sandbox (you can switch php versions there)

There's also a discussion in Drupal forums

As a quickfix I suggest this:

$query = @array_diff($params, array('f' => array()));

And in case you're going to use array_diff function with deep arrays, there are plenty of solutions on the net, including official php.net resource.

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.