¿Qué tal esto?
/**
* Like explode with multiple delimiters.
* Default delimiters are: \ | / and ,
*
* @param string $string String that thould be converted to an array.
* @param mixed $delimiters Every single char will be interpreted as an delimiter. If a delimiter with multiple chars is needed, use an Array.
* @return array. If $string is empty OR not a string, return false
*/
public static function multiExplode($string, $delimiters = '\\|/,')
{
$delimiterArray = is_array($delimiters)?$delimiters:str_split($delimiters);
$newRegex = implode('|', array_map (function($delimiter) {return preg_quote($delimiter, '/');}, $delimiterArray));
return is_string($string) && !empty($string) ? array_map('trim', preg_split('/('.$newRegex.')/', $string, -1, PREG_SPLIT_NO_EMPTY)) : false;
}
En su caso, debe usar una matriz para el parámetro $ delimiters. Entonces es posible usar múltiples caracteres como un delimitador.
Si no le interesan los espacios finales en sus resultados, puede eliminar la array_map('trim', [...] )parte en la fila de retorno. (Pero no seas un discutidor en este caso. Mantén elpreg_split ).
Versión PHP requerida: 5.3.0 o superior.
Puedes probarlo aquí