本文介绍了的SimpleXMLElement和警告:非法偏移类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
警告:非法偏移类型
我从一个XML输出这个VAR
i have this var from an xml output
var_dump($key);
它给我
object(SimpleXMLElement)#11 (1) { [0]=> string(5) "Cairo" }
现在我想使开罗作为一键搞定像
now i want make "Cairo" as a key to get its value like
$lang[] = array('Cairo' => "Cairo city");
做到这一点,当错误出现
the error appear when do this
echo $lang[$key];
和它给我的警告:非法偏移类型,因为关键的是的SimpleXMLElement
我怎么可以让它正常的变种?
and its give me the "Warning: Illegal offset type" because of the key is SimpleXMLElement
how i can make it normal var?
推荐答案
它转换为字符串(字符串)$键
。
这篇关于的SimpleXMLElement和警告:非法偏移类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!