-2

I have a string as mention below

$string = 20181123091338,20181130070940;

Now, I want to convert this string into an array format like

$array = array("20181123091338","20181130070940");

So, How can I do this? Please help me.

Thank You

Bruce
  • 51
  • 7

1 Answers1

1

You can use explode() .

Try this

$string = "20181123091338,20181130070940";
$arr = explode(",", $string);
echo "<pre>"; print_r($arr);

Explaination

Here we are exploding string by ","(comma), so we are passing ,(comma) as first parameter in explode function and string passing as second parameter.

shubham715
  • 3,324
  • 1
  • 17
  • 27
  • it show me `Array ( [0] => 20181123091338 [1] => 20181130070940 )` but I want this formate `array("20181123091338","20181130070940")` @shubham715 – Bruce Dec 07 '18 at 05:14
  • 3
    both is same @Bruce. Array always maintain keys , if you create array like this array("20181123091338","20181130070940") and then print outout , it will be same like above output. – shubham715 Dec 07 '18 at 05:15