我在使用laravel插入数据时遇到了一些迁移麻烦。我收到以下错误:
ErrorException:未初始化的字符串偏移量:16
我不明白为什么,这是我的代码:
//above is curl codes with no problem there
$veri = curl_exec($curl);
preg_match_all('@cassette-header">(.*?)<a href="/(.*?)"@si', $veri, $url);
$say = count($url[2]);
if($say > 0) {
for ($i=0; $i<$say; $i++) {
$link ="https://suumo.jp/".$url[2][$i];
$address = $veri = file_get_contents($link);
preg_match_all('@<h1>(.*?)</h1>@si',$address, $bina);
$name = strip_tags(trim($bina[0][0]));
preg_match_all('@<span class="l-quickright">(.*?)<span class="l-quickright-item">@si',$address, $adres);
$addr = strip_tags(trim($link = $adres[0][0]));
preg_match_all('@<span class="l-quickright">(.*?)<span class="l-quickright-item">@si',$veri, $genislik);
$extent = strip_tags(trim($genislik[0][2]));
preg_match_all('@<td class="detailtable-body">(.*?)</td>@si',$veri, $extentwo);
$extenttwo = strip_tags(trim($extentwo[0][3]));
preg_match_all('@<td class="detailtable-body">(.*?)</td>@si',$veri, $fiyat);
$rent = strip_tags(trim($fiyat[0][4]));
preg_match_all('@<td class="detailtable-body">(.*?)</td>@si',$veri, $buy);
$time = strip_tags(trim($buy[0][5]));
preg_match_all('@<td class="detailtable-body">(.*?)</td>@si',$veri, $buytwo);
$timetwo = strip_tags(trim($buytwo[0][6]));
$data[] = [
'Links' => $link[$i],
'Building Names' => $name[$i],
'Addresses' => $addr[$i],
'Rooms' => $extent[$i],
'Extents' => $extenttwo[$i],
'Rents' => $rent[$i],
'Sales Start' => $time[$i],
'Move In' => $timetwo[$i],
];
}
}
DB::table('estates')->insert($data);
我收到“ ErrorException:未初始化的字符串偏移量:16”错误。但是我不明白为什么?谢谢您的帮助!