php string split by comma code example

Example 1: explode comma php

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

Example 2: php split string

<?php
// It doesnt get any better than this Example
$pizza  = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2

Example 3: 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"

Example 4: php split string

explode(" ","Geeks for Geeks")

Example 5: character split php

str_split ( string $string [, int $split_length = 1 ] ) : array

Tags:

Sql Example