[英]populating php array variable is not working in godaddy server(php version 5.3.24) works perfectly in localhost
I am trying to create an array by using xml file. 我正在尝试使用xml文件创建一个数组。 but when i run the code in server (php version 5.3.24) am getting an error.
但是当我在服务器(php版本5.3.24)中运行代码时出现错误。 But tihis is working perfectly in localhost (php version 5.3.5)
但是这在localhost中完美运行(php版本5.3.5)
Parse error: syntax error, unexpected '[' in /home/content/61/10253461/html/crm/xmas/src.php on line 28
解析错误:语法错误,第28行/home/content/61/10253461/html/crm/xmas/src.php中的意外'['
the 28th line is $allowed[$i]=(int)$a->attributes()[1]; 第28行是$ allowed [$ i] =(int)$ a-> attributes()[1]; in the following code
在以下代码中
function parcexml(){
$xml=simplexml_load_file("emaillist.xml");
$allowed=array();
$fname=array();
$femail=array();
$f1=array();
$f2=array();
$i=0;
foreach($xml->email as $a) {
$allowed[$i]=(int)$a->attributes()[1];
$fname[$i]=$a->attributes()[0];
$femail[$i]=$xml->children()[$i];
$i++;
}
}
please specify any solution. 请指明任何解决方案。
Change it to: 将其更改为:
function parcexml(){
$xml=simplexml_load_file("emaillist.xml");
$allowed=array();
$fname=array();
$femail=array();
$f1=array();
$f2=array();
$i=0;
foreach($xml->email as $a) {
$temp=(int)$a->attributes();
$allowed[$i]=$temp[1];
$fname[$i]=$temp[0];
$temp=$xml->children();
$femail[$i]=$temp[$i];
$i++;
}
}
So on your scenario do like this... 所以在你的场景中这样做......
Instead of 代替
$fname[$i]=$a->attributes()[0];
Do like 喜欢
$v = $a->attributes();
$fname[$i] = $v[0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.