在php中拆分字符串

在php中拆分字符串,php,Php,下面的字符串我需要分裂。我尝试使用php explode函数 $link= 7_5_7_http://test.com/folder/images/7_newim/5_car/7_february2013/p/a00/p01/video-1.mov_00:00:09; $ex_-link=分解“,$link 但它是在每个u'符号后拆分字符串。但我需要像这样来解释结果 $ex_link[0] ==> 7; $ex_link[1] ==> 5; $ex_link[2] ==> 7;

下面的字符串我需要分裂。我尝试使用php explode函数

$link= 7_5_7_http://test.com/folder/images/7_newim/5_car/7_february2013/p/a00/p01/video-1.mov_00:00:09;

$ex_-link=分解“,$link

但它是在每个u'符号后拆分字符串。但我需要像这样来解释结果

$ex_link[0] ==> 7;
$ex_link[1] ==> 5;
$ex_link[2] ==> 7;
$ex_link[3] ==> http://test.com/folder/images/7_newim/5_car/7_february2013/p/a00/p01/video-1.mov;
$ex_link[2] ==> 00:00:09;
有什么想法可以做到这一点

提前感谢

使用

preg_match('/(\d)_(\d)_(\d)_([\w:\.\/\/\-]+)_([\d]{2}:[\d]{2}:[\d]{2})/', $link, $matches);
和$matches:

array(6) {
  [0]=>
  string(95) "7_5_7_http://test.com/folder/images/7_newim/5_car/7_february2013/p/a00/p01/video-1.mov_00:00:09"
  [1]=>
  string(1) "7"
  [2]=>
  string(1) "5"
  [3]=>
  string(1) "7"
  [4]=>
  string(80) "http://test.com/folder/images/7_newim/5_car/7_february2013/p/a00/p01/video-1.mov"
  [5]=>
  string(8) "00:00:09"
}
使用

和$matches:

array(6) {
  [0]=>
  string(95) "7_5_7_http://test.com/folder/images/7_newim/5_car/7_february2013/p/a00/p01/video-1.mov_00:00:09"
  [1]=>
  string(1) "7"
  [2]=>
  string(1) "5"
  [3]=>
  string(1) "7"
  [4]=>
  string(80) "http://test.com/folder/images/7_newim/5_car/7_february2013/p/a00/p01/video-1.mov"
  [5]=>
  string(8) "00:00:09"
}
还有第三个参数,为什么人们要把事情复杂化

输出:

还有第三个参数,为什么人们要把事情复杂化

输出:


这个是最简单的

$result = preg_split('%_(?=(\d|http://))%si', $subject);

这个是最简单的

$result = preg_split('%_(?=(\d|http://))%si', $subject);

看一看并开始。看一看并开始。cool@HamZaDzCyberDeV。尽管有点复杂,但问题已经解决。谢谢你的解决方案。cool@HamZaDzCyberDeV。尽管有点复杂,但问题已经解决了。谢谢你的解决方案。很好,我正在考虑一个preg_split的解决方案,而你也带来了+1!很好,我在想一个preg_split的解决方案,而你却得到了+1!