2

I have this existing code does not work as I am trying to get flashvars , itemId value to be taken for some purpose. How can I parse and take it?

i need the value 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);




?>
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
Loganathan Natarajan
  • 340
  • 1
  • 10
  • 26
  • possible duplicate of [Best methods to parse HTML](http://stackoverflow.com/questions/3577641/best-methods-to-parse-html) – Pekka Apr 28 '11 at 09:29

2 Answers2

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

preg_match('/itemId=([a-zA-Z0-9]+)/', $result, $matches);
$output = $matches[1];
hsz
  • 148,279
  • 62
  • 259
  • 315
0
preg_match("!<embed.*?itemId=([^&]+).*?>.*?</embed>!sm",$result,$match);
NikiC
  • 100,734
  • 37
  • 191
  • 225