php - 有没有办法对数组进行子串化?
问题描述
我想对查询给出的数组进行子串化
CONTROLLER(EX. 值(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)}}
错误
substr() expects parameter 1 to be string, object given
解决方案
您错误地解析了结果。(避免使用变量名$this
)
$store=array();
$tables = \DB::select("SHOW TABLES WHERE Tables_in_database LIKE '%Year_Report_%'");
foreach($tables as $table){
$store[] = substr($table->Tables_in_database,-4);
}
推荐阅读
- python - 始终从 clf 模型中获取相同的数据。如何使用 sklearn 正确克隆?
- powershell - 将文本文件中的内容添加到变量内容的末尾
- javascript - 尽管不存在错误,但 Google 脚本不会触发电子邮件警报
- python - 如何在python中将画布的内容导出到ps
- c# - 如何根据另一个列表中的索引从列表中获取子列表?
- windows - 永久添加 PowerShell 模块?(导入模块)
- python - 如何连接具有相同行数的 numpy.ndarray 和 scipy.sparse.csr.csr_matrix?
- python - 有什么好的方法可以创建一个简单但好看的网页,该网页构建 Excel 文件的报告并显示 Pandas 数据框和绘图?
- tensorflow - 将 TensorFlow 分布更新为 TensorFlow 概率
- javascript - 如果元素必须换行,则将 flexbox 子元素的宽度扩大到 100% - jquery 或 javascript?