For example, the article content contains the following link address:
This is MKV video test
This is the MOV video test
This is the SWF video test
This is AVI video test
This is the MP4 video test.
I want to get the following result through the regular:
Array
url = mkv_test.mkv,
title = This is MKV video test
)
Array
url = Mov_test.mov,
title = This is MOV video test
)
Array
url = swf_test.swf,
title = This is the SWF video test
)
......
Ask how to write the regular, anxious to beg for urgent
Reply to discussion (solution)
$s = <<< txt This is the MKV video test which is the MOV video test which is the SWF video test which is the AVI video test which is the MP4 video test txt;preg_match_all ('/href= ' (. +) "> (. +) $v) { $arr [] = array (' url ' = = $v, ' title ' = [2][$k]);} Print_r ($arr);
$STR = <<< Mark this is the MKV video test which is the MOV video test which is the SWF video test which is the AVI video test which is the MP4 video test mark; $rule = ' #\ (. *?) \<\/a># ';p reg_match_all ($rule, $str, $arr), $item =array (), foreach ($arr [1] as $k + = $v) { $item []=array (' URL ' = ' $v, ' title ' and ' = ' $arr [2][$k]);} Print_r ($item);
Array ( [0] = = Array ( [url] + mkv_test.mkv [title] = = This is MKV video test ) [1] = = Array ( [url] = = Mov_test.mov [title] and this is MOV video test ) [2] = = Array ( [url] = swf _test.swf [title] = = This is the SWF Video test ) [3] = = Array ( [url] = Avi_test.avi [title] = = This is the AVI video test ) [4] = = Array ( [url] = = Mp4_test.mp4 [title] + = This is MP4 video test) )
$STR = <<< Mark this is the MKV video test which is the MOV video test which is the SWF video test which is the AVI video test which is the MP4 video test mark; $rule = ' #\ (. *?) \<\/a># ';p reg_match_all ($rule, $str, $arr), $item =array (), foreach ($arr [1] as $k + = $v) { $item []=array (' URL ' = ' $v, ' title ' and ' = ' $arr [2][$k]);} Print_r ($item);
Array ( [0] = = Array ( [url] + mkv_test.mkv [title] = = This is MKV video test ) [1] = = Array ( [url] = = Mov_test.mov [title] and this is MOV video test ) [2] = = Array ( [url] = swf _test.swf [title] = = This is the SWF Video test ) [3] = = Array ( [url] = Avi_test.avi [title] = = This is the AVI video test ) [4] = = Array ( [url] = = Mp4_test.mp4 [title] + = This is MP4 video test) )
Thank you for two big answer, the problem has been solved perfectly
Thank you for two big answer, the problem has been solved perfectly