preg-split
Split string by delimiter, but not if it is escaped
Use dark magic: $array = preg_split(‘~\\\\.(*SKIP)(*FAIL)|\|~s’, $string); \\\\. matches a backslash followed by a character, (*SKIP)(*FAIL) skips it and \| matches your delimiter.
Explode string on commas and trim potential spaces from each value
You can do the following using array_map: $new_arr = array_map(‘trim’, explode(‘,’, $str));