简体   繁体   中英

Split string based on a series of characters

I want to know how i can split a string in php based on a series of characters. Like for example, i have a string as: a^b^^c^^^d^^^^e

Now how i can break this string into an array as: a,b,c,d,e ? The php explode function does not seem to work here....

Please help..

您可以使用preg_split函数:

$array = preg_split("/\^+/", $str);

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