简体   繁体   中英

Splitting string into words in php

I need to split a string to array of words by using all the non alphabetic and numeric characters(including '_') as delimiter my present code is here

$result= wordarray(preg_split("#[&,$'_.;:\s-*]# ", $data));  

AS you can see it can't work for these characters

)(@#+-*/=!~`/ \\

Please help me by adding this characters to the code.

Thanks in advance.

您可以将^用作非运算符...

$result= preg_split("/[^A-Za-z0-9]/", $data);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM