$data = file_get_contents($file);
$fexplode = explode(PHP_EOL, $data);
foreach ($fexplode as $uline) {
foreach (unserialize($uline) as $item => $value){
echo $item . " : ";
echo $value;
}
}
运行此代码时,在我的页面上出现“警告:为foreach()提供的参数无效”警告
答案 0 :(得分:0)
以下方式使用
$data = file_get_contents($file);
$fexplode = (!empty($data)?explode(PHP_EOL, $data):array()); // use !empty otherwise make empty array
foreach ($fexplode as $uline) {
foreach (unserialize($uline) as $item => $value){
echo $item . " : ";
echo $value;
}
}