Convert Comma Seprated Interger to Array in PHP

Split a comma delimited string into an array in PHP



Method 1 -

<?php
  
// Use preg_split() function
$string = "67,68"; 
$str_arr = preg_split ("/\,/", $string); 
print_r($str_arr);
      
?>

Method 2 -

<?php 

// use of explode
$string = "67,68";
$str_arr = explode (",", $string); 
print_r($str_arr);

?>

Comments