array_diff在drupal中将数组转换为字符串转换错误 [英] array_diff gives Array to String conversion error in drupal

查看:125
本文介绍了array_diff在drupal中将数组转换为字符串转换错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了来自array_diff语句的奇怪错误.声明是:

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

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

并且$paramsvar_dumparray(1) { ["f"]=> array(0) { } }

这发生在名为Islandora_solr_search的drupal模块中,并且出现如下所示的两次错误消息

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

注意:IslandoraSolrResults-> setBreadcrumbs()中的数组到字符串的转换(/var/www/drupal/sites/all/modules/islandora_solr_search/includes/results.inc的第427行).

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

注意:IslandoraSolrResults-> setBreadcrumbs()中的数组到字符串的转换(/var/www/drupal/sites/all/modules/islandora_solr_search/includes/results.inc的第427行).

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?

推荐答案

array_diff在数组中找到数组时会引发通知错误.请参见Michiel Thalen的评论

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

我可能认为您运行的是php 5.4或更高版本.您可以通过检查沙盒中的array_diff语句来自己查看(可以在此处切换php版本)

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)

Drupal论坛中也有讨论

作为一个快速修复,我建议这样做:

As a quickfix I suggest this:

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

如果要对深层数组使用array_diff函数,则有很多 网络上的解决方案,包括官方的php.net资源.

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.

这篇关于array_diff在drupal中将数组转换为字符串转换错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆