The following line splits a string by any combination of whitespace (including newlines) and commas:

<?php
$splitArray = preg_split("/[\s,]+/", $input);
?>