php string to array by comma code example

Example 1: explode comma php

$myString = "9,[email protected],8";
$myArray = explode(',', $myString);
print_r($myArray);

Example 2: array to string separated by comma php

$arr = array ( 0 => "lorem", 1 => "ipsum", 2 => "dolor");

$str = implode (", ", $arr);

Example 3: create array from string with commas php

$myString = "9,[email protected],8";
$myArray = explode(',', $myString);
print_r($myArray);

Example 4: how to convert array to string with commas in php

$tags = implode(', ', array('tag1','tag2','tag3','tag4'));

Example 5: how to convert array to string with commas in php

$string = implode(', ', $tags);

Example 6: split array with comma php

// ------------------------------------------------
// php implode / explode

"expiry": [
  "94 Paracoins will expiry date 2020-10-28",
  "20 Paracoins will expiry date 2020-12-15",
  "2 Paracoins will expiry date 2020-12-20",
  "2 Paracoins will expiry date 2021-01-22",
  "8 Paracoins will expiry date 2021-01-28"
]

$expiry = implode(", ", $expiry);

//=> $expiry_message 
=> $expiry = "94 Paracoins will expiry date 2020-10-28, 20 Paracoins will expiry date 2020-12-15, 2 Paracoins will expiry date 2020-12-20, 2 Paracoins will expiry date 2021-01-22, 8 Paracoins will expiry date 2021-01-28"

Tags:

Php Example