2011-04-28 29 views
2

我有这个现有的代码不起作用,因为我想获取flashvars,itemId值是为了某种目的而采取的。我如何解析并采取它?如何解析嵌入对象并从此使用PHP获取flashvars值?

我需要的值为itemid = “OWYrYlg5VW9GZUI4UjVnMXFOUGsrQT09”

<?php 
$result = '<embed src=\'http://www.test.com//test_1.swf\' quality="high" FlashVars="itemId=OWYrYlg5VW9GZUI4UjVnMXFOUGsrQT09&autoplay=0&duration=02:45&url=http://test.com" bgcolor="#ffffff" wmode="opaque" width="320" height="65" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>'; 

//preg_match("/\<embed.*itemId\=\"(.+)\".*\>.*\<\/embed\>/Us",$result,$match); 

parse_str($result, $output); 

print '<pre>'; 
print_r ($output); 




?> 
+0

可能重复的具体实施方法,以解析HTML(http://stackoverflow.com/questions/3577641/best- methods-to-parse-html) – 2011-04-28 09:29:03

回答

1
$result = 'your string'; 
$output = ''; 

preg_match('/itemId=([a-zA-Z0-9]+)/', $result, $matches); 
$output = $matches[1]; 
+0

非常感谢你... – logudotcom 2011-04-28 10:20:43

0
preg_match("!<embed.*?itemId=([^&]+).*?>.*?</embed>!sm",$result,$match); 
+0

both are works fine..great,非常感谢你的专家... – logudotcom 2011-04-28 10:21:55