我有这个现有的代码不起作用,因为我试图获取flashvars,itemId值为某些目的。我该如何解析并接受它?
我需要值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 :(得分:1)
$result = 'your string';
$output = '';
preg_match('/itemId=([a-zA-Z0-9]+)/', $result, $matches);
$output = $matches[1];
答案 1 :(得分:0)
preg_match("!<embed.*?itemId=([^&]+).*?>.*?</embed>!sm",$result,$match);