tags:

views:

22

answers:

2
<script type="text/javascript"><!-- 
Vertical1_437 = "false-2010";
ShowAdHereBanner1437 =" true";
RepeatAll1437 = "true";
NoFollowAll1437 ="true";
//-->
</script> 

I'm trying to get the 2010 part out of the false-2010. i want it to echo 2010 only.. Thanks for the help.

this was what i started with and got stuck

<?php
$get2010 = preg_match('/\<!--(.*?)-->/', $get2010, $m);
echo $m[1]; 
?>

and oh.. the 2010 is a randomly generated number... it changes.

A: 
preg_match('!Vertical1_437\s*=\s*"\D+(\d+)"!', $get2010, $m);
echo $m[1];

This assumes it's always the RHS of Vertical1_437. I am also assuming you have that block of HTML code as a string in $get2010.

quantumSoup
A: 

It may be helpful if you could be more specific about what data is dynamic and what is static. If Vertical1_437 and false are static and the 2010 part is the only dynamic part, then this should work:

preg_match{'#(.*Vertical1_437.*false-)(\d{1,4})(.*)#', $get2010, $m);
echo $m[2];

Mine assumes that "2010" is a digit that is 1-4 digits, you can adjust that in the {1,4} part.

This should do it for the given example. If some of that other text is dynamically generated, then There will probably be something to change.

Tim