首页 > 解决方案 > 以数组格式传递数字 - 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初学者

标签: phplaravel

解决方案


在执行 json_encode 之前将其分解

$numbers = explode(',', $payloadArray[1]);

推荐阅读