我想对查询给定的数组进行子字符串化
CONTROLLER(例如,值(Year_Report_2019,Year_Report_2020)
$store=array();
$tables = \DB::select("SHOW TABLES WHERE Tables_in_database LIKE '%Year_Report_%'");
foreach($tables as $this){
$get= substr($this,-4);
$store[] = $get;
}
BLADE想要显示(2019,2020)的结果
{{implode(",", $store)}}
ERROR
substr() expects parameter 1 to be string, object given
您解析结果错误。 (避免使用变量名$this
)
是,implode
功能将为您完成:
$array = ['Year_Report_2019','Year_Report_2020'];
array_walk($array, function(&$item) {
return $item = preg_replace("/\D/", '', $item);
});
这里无需使用foreach,只需用您的愿望表达将这个数组内陷