php - 以数组格式传递数字 - Laravel
问题描述
我正在尝试在下面的代码中将字符串转换为数组格式。我尝试使用爆炸,但它返回我的结果为
在我的代码中我有
文件.php
$dial_deustche_no = $payloadArray[1];
dial_deustche_no = 49744990,49010101 //result
$numbers = json_encode([0 => $dial_deustche_no]);
$numbers =. ["49744990,49010101"] //result
当我使用爆炸结果看起来像
explode(',', $numbers);
//results
array (
0 => '["49744990',
1 => '49010101"]',
)
这就是我希望我的结果看起来像的样子
$numbers = ['49744990','49010101']
PS:laravel PHP初学者
解决方案
在执行 json_encode 之前将其分解
$numbers = explode(',', $payloadArray[1]);
推荐阅读
- vue.js - Saas 加载器的模块构建失败 - NuxtJS
- python - 如何将字典写入文本文件,其中包含 Python 中字典中每个元素的列
- powershell - PowerShell - 列出所有文件夹、子文件夹和每个包含的文件(递归)但以格式化方式(树视图)
- angular - 我收到来自未知元素的错误
- r - 在R中固定拉长的图形彼此相邻
- python - Discord.py 输出时没有反应表情符号
- docker - Jenkins 管道无法在 Jenkins 节点上运行远程脚本
- postgresql - 没有显式类型转换的 pg_restore 上不提供几何等式运算符
- python - How to cast values to custom type in SQLAlchemy with Postgres
- passport.js - 在使用 passport-github 时,尽管 user:email 范围,但 profile.emails 为空