Skip to content
Advertisement

Passing Numbers in array format – Laravel [closed]

I am trying to convert string to an array format in my code below. I tried to use explode but it returns my results as

In my code i have

File.php

  $dial_deustche_no =  $payloadArray[1];

  dial_deustche_no =  49744990,49010101  //result

 $numbers = json_encode([0 => $dial_deustche_no]);
 
 $numbers =. ["49744990,49010101"]  //result

When i use explode results looks like

 explode(',', $numbers);

 //results

array (
  0 => '["49744990',
  1 => '49010101"]',
)  

This is how i want my results to look like

$numbers = ['49744990','49010101']

PS: Beginner in laravel PHP

Advertisement

Answer

Explode it before doing the json_encode

$numbers = explode(',', $payloadArray[1]);
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement