I want to explode a string for all:
- whitespaces (\n \t etc)
- comma
- hyphen (small dash). Like this >> –
But this does not work:
$keywords = explode("\n\t\r\a,-", "my string");
How to do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Explode can’t do that. There is a nice function called
preg_splitfor that. Do it like this:This outputs:
BTW, do not use
split, it is deprecated.