The research long time didn't get it right.
Will
/aaa/bbb/ccc
Split into
/aaa
/bbb
/ccc
I didn't write that right.
Preg_match ('/(\/\w+) +/i ', '/AAA/BBB/CCC ', $matches);
Reply to discussion (solution)
Be sure to use the regular, I think with explode function is also good AH.
$str = '/AAA/BBB/CCC '; $matches = explode ('/', $str); Explodeecho '/'. $matches [1]; /aaaecho '/'. $matches [2]; /bbbecho '/'. $matches [3]; /cccpreg_match_all (' @\/[a-z]{3}@i ', $str, $matches); Regular echo $matches [0][0]; /aaaecho $matches [0][1]; /bbbecho $matches [0][2]; /ccc
To write like this.
Preg_match_all ('/(\/\w+)/I ', '/AAA/BBB/CCC ', $matches);
$matches [1] that is
3 Floor positive solution, is to match all the requirements, so to use the function Preg_match_all.
Personally feel that there is no need to use the regular, explode () can completely achieve the results you want, why should shejinqiuyuan it, of course, also depends on the actual situation ....