Splitting and Joining

explode($separator, $string, $limit) splits on a fixed string: a positive limit caps the pieces and leaves the rest in the last one, and a negative limit drops pieces from the end. implode() joins. str_split() cuts fixed-width chunks (returning [] for '' since PHP 8.2), and str_getcsv() parses a CSV line with quoted fields.

Splitting tag lists, e-mail addresses and CSV (split.php)PHP
<?php
$tags = 'php, mysql,, apache ,linux';
echo json_encode(explode(',', $tags)), "\n";
echo json_encode(array_values(array_filter(array_map(trim(...), explode(',', $tags))))), "\n";
[$user, $domain] = explode('@', 'ada@example.com', 2);
echo "$user at $domain; ", json_encode(explode('/', 'a/b/c/d', -1)), ' ',
    implode(', ', ['PHP', 'MySQL']), "\n";
echo json_encode(str_getcsv('42,"Smith, Jane","say ""hi""",19.99', escape: '')), "\n";
Output
["php"," mysql",""," apache ","linux"]
["php","mysql","apache","linux"]
ada at example.com; ["a","b","c"] PHP, MySQL
["42","Smith, Jane","say \"hi\"","19.99"]

User-typed lists need the trim-and-filter step. Pass a limit of 2 when you split into two parts, so a second @ cannot shift fields. For CSV, pass escape: '': relying on the default backslash is deprecated as of PHP 8.4, and RFC 4180 files expect no escape character. Files stream with fgetcsv() (Files, Directories and Streams).