How can I parse flashvars from EMBED tag string?

I have the EMBED string like this and want to get only the flashvars variable as itemId=OWYrYlg5VW9GZUI4UjVnMXFOUGsrQT09 .. i need only "OWYrYlg5VW9GZUI4UjVnMXFOUGsrQT09" .. how can i read this from the below attached string?
<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>

Open in new window

LVL 36
Loganathan NatarajanLAMP DeveloperAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
Try this:
preg_match('/flashvars="[^"]*itemId=([^&"]+)/i', $sourceString, $match);
echo $match[1];

Open in new window

0
 
deepanjandasCommented:
First, I feel you have posted in the wrong zone, so kindly update the zones to Adobe Flash/ActionScript.
Now, if you are using AS2, then do this to get the itemId:

var itemId:String= _root.itemId;

For AS3:
var itemId:String = loaderInfo.parameters.itemId;


Hope this helps.

Warm Regards
Deepanjan Das
0
 
Loganathan NatarajanLAMP DeveloperAuthor Commented:
No, I am looking some preg_match way to parse or split the above EMBED tag.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
deepanjandasCommented:
Opps I am sorry :)

Not sure about the php method much but with javascript try this logic:
Split by "itemId=" and then again split the second element by "&" to get the itemId value.

Warm Regards
Deepanjan Das
0
 
Mohamed AbowardaSoftware EngineerCommented:
Find string position of the first equal char "=" and then sub string the value to get the value after the first equal "=".
0
 
Mohamed AbowardaSoftware EngineerCommented:
Use something familiar to the following:
var i = myString.indexOf("=");
myString = myString.substr(i, myString.length);

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperAuthor Commented:
thank you
0
 
käµfm³d 👽Commented:
NP. Glad to help  : )
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.