php - explode column from database
问题描述
Hi every I need to get product from the database and explode it in one line of code So I can get product data and get product_properties as an array together
$Product = Product::find(33);
$properties = explode(",", ($Product ->product_properties));
解决方案
You can achieve it doing:
$properties = explode(",", (Product::find(33)->product_properties));
But this is poor in readability compared with your first approach.
推荐阅读
- javascript - 将现有函数作为静态方法添加到类(javascript / es6)
- javascript - 为什么调用 stroke 会导致这个元素被绘制在 HTML 画布上?
- sql-server-2008 - 如何在 SQL Server 中对 varbinary 数据类型进行按位运算
- neo4j - 如何让neo4j只检查键是否重复而不检查其他属性
- javascript - 无法将属性“onfocus”设置为 null
- c# - .Net Core 重置密码令牌和 Identityserver 4 令牌无效
- crystal-reports - 水晶报表和 TLS 1.2
- android - Android Studio 3.1.3 错误:视图不受约束。如何永久解决这个问题?
- amazon-web-services - AWS Neo4j 连接问题
- c# - 来自 PostAsync 的内部服务器错误