I explored all the previous questions and solutions, nut none of them works in my situation.
I have an input text area where accepts employee ids. End users could use comma , enter, space to separate multiple employee ids, and I need to change any separation into commas.
This is my code:
$emplids = preg_replace('/[,\t\n\r\s]+/',",",$emplids);
And then, I need to only keep the numbers and commas:
$emplids = preg_replace("/[^X0-9,]/", "", $emplids);
And then I need to store them into anarray:
$emplids = explode(",", $emplids);
Now only the end users put comma among employee ids could work, line breaks could not work.
I tried double quotas:
$emplids = preg_replace("/[,\t\n\r\s]+/",",",$emplids);
It doesn't work neither.
It seems like a tiny question, but it really takes me hours. And any hints is highly appreciated!