且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在PHP中的非字母数字上拆分字符串? PHP的本机功能是否可能?

更新时间:2023-02-21 12:47:21

听起来像 array_walk()

Sounds like a case for str_word_count() using the oft forgotten 1 or 2 value for the second argument, and with a 3rd argument to include hyphens, full stops and apostrophes (or whatever other characters you wish to treat as word-parts) as part of a word; followed by an array_walk() to trim those characters from the beginning or end of the resultant array values, so you only include them when they're actually embedded in the "word"