Convert comma separated string into array

See dedicated page here.

    $MyCommaSeperatedString = rtrim(trim("abc,def,ghi,"), ",");      //Ensure there is no trailing comma
    $MyArray = explode(',', $MyCommaSeperatedString);    //Convert to array (No commas will result in the text in the string being in an array of length 1)
    print_r($MyArray);
    //Will output: Array ( [0] => abc [1] => def [2] => ghi )

Convert array to comma separated string

See dedicated page here.

  $MyCommaSeperatedString = implode(',', $MyArray);

Convert string to byte array

  $my_memory_array = array_slice(unpack('C*', "\0".$my_string), 1);

json encode

See here