PHP Split String

PHOTO EMBED

Wed Aug 03 2022 12:21:58 GMT+0000 (UTC)

Saved by @kalehm

<?php
  
// Use preg_split() function
$string = "123,456,78,000"; 
$str_arr = preg_split ("/\,/", $string); 
print_r($str_arr);
      
// use of explode
$string = "123,46,78,000";
$str_arr = explode (",", $string); 
print_r($str_arr);
?>


Output:
Array
(
    [0] => 123
    [1] => 456
    [2] => 78
    [3] => 000
)
Array
(
    [0] => 123
    [1] => 46
    [2] => 78
    [3] => 000
)
content_copyCOPY

https://www.geeksforgeeks.org/split-a-comma-delimited-string-into-an-array-in-php/