Siyad M
Siyad M

Reputation: 131

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.

Upvotes: 0

Views: 478

Answers (1)

SQL Hacks
SQL Hacks

Reputation: 1332

You can use ^ as a not operator...

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

Upvotes: 1

Related Questions