简体   繁体   English

PHP阵列上的严格标准消息

[英]Strict Standards message on php array

I currently am getting the following error message when splitting out array values by character: Strict Standards: Only variables should be passed by reference 当按字符分割数组值时,我当前收到以下错误消息: 严格的标准:仅变量应通过引用传递

This is my array: 这是我的数组:

array(6) { [0]=> string(8) "2390:SS0" [1]=> string(8) "2391:SS1" [2]=> string(9) "2392:SS11" [3]=> string(7) "250:BS1" [4]=> string(8) "251:BS10" [5]=> string(8) "252:BS11" }

This is my php: 这是我的PHP:

foreach ($postcodes as $key => $value)
{
  $postcode_ids     = current(explode(':', $value));
  $postcode         = next(explode(':', $value));
}

The notice seems to appear on the next line? 该通知似乎出现在下一行? Any ideas or pointer would be great. 任何想法或指针都很好。 Thanks. 谢谢。

next() modifies the array that you pass in. It is passed by reference. next()修改您传入的数组。它通过引用传递。 Therefore you cannot use 因此,您不能使用

next( [expression] );

but only 但只有

next( [variable] );

To simplify your code, replace 为了简化您的代码,请替换

 $postcode_ids     = current(explode(':', $value));
 $postcode         = next(explode(':', $value));

with

 list($postcode_ids, $postcode) = explode(':', $value);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM