按字符拆分数组值时,我当前收到以下错误消息:严格标准:只有变量才能通过引用传递
这是我的阵列:
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" }
这是我的php:
foreach ($postcodes as $key => $value)
{
$postcode_ids = current(explode(':', $value));
$postcode = next(explode(':', $value));
}
通知似乎出现在下一行?任何想法或指针都会很棒。谢谢
next()修改您传入的数组。它是通过引用传递的。因此,您不能使用
next( [expression] );
但只有
next( [variable] );
为了简化代码,请更换
$postcode_ids = current(explode(':', $value));
$postcode = next(explode(':', $value));
带有
list($postcode_ids, $postcode) = explode(':', $value);