![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Mike - If I'm reading this right, you just want to extract the "2" from the first line and "10" from the second. If that's the case, try this: $line = ...one of your lines... $result = array(); preg_match("/^.* of (about |)<B>([0-9]+)<\/B>.*$/",$line,$result); $total = $result[2]; and $total will be "2" for the first line, "10" for the second. hth Kurt Milligan M.I. wrote: > Hi Gurus, > Sorry for crossposting to alt.comp.lang.php > > I start with a line that has 2 versions > 1-<TD noWrap align=right bgColor=#3366cc><FONT color=#ffffff size=-1>Results > <B>1</B> - <B>2</B> of <B>2</B>. Search took <B>0.05</B> > seconds.</FONT></TD></TR> > > 2- <TD noWrap align=right bgColor=#3366cc><FONT color=#ffffff > size=-1>Results <B>1</B> - <B>7</B> of about <B>10</B>. Search took > <B>0.08</B> seconds.</FONT> > > Where the numbers will always change. > I'm trying to extract the third number (*2* in example 1, *10* in example 2) > > I have this routine that only works with example 2 but not with example 1, > how can I get it to work with both examples? > > $total = $line; > $total = preg_replace("/^.*of about <b>/", "", $total); > $total = preg_replace("/^.*of <b>/", "", $total); > $total = preg_replace("/<.*$/", "", $total); > $total = preg_replace("/\,/", "", $total); > $total = trim($total); > return($total); > > Or is there a better way? > > Thanks again. > Mike > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.493 / Virus Database: 292 - Release Date: 26/06/2003 > > | |||
|
| | #2 | ||
| Thanks! "Kurt Milligan" <junk@atNOSPAMmilliganshome.net> wrote in message news:moqdnX94DZJE54yiXTWJjQ@comcast.com... > Mike - > > If I'm reading this right, you just want to extract the "2" from the > first line and "10" from the second. If that's the case, try this: > > $line = ...one of your lines... > > $result = array(); > preg_match("/^.* of (about |)<B>([0-9]+)<\/B>.*$/",$line,$result); > > $total = $result[2]; > > and $total will be "2" for the first line, "10" for the second. > > hth > Kurt Milligan > > > > M.I. wrote: > > Hi Gurus, > > Sorry for crossposting to alt.comp.lang.php > > > > I start with a line that has 2 versions > > 1-<TD noWrap align=right bgColor=#3366cc><FONT color=#ffffff size=-1>Results > > <B>1</B> - <B>2</B> of <B>2</B>. Search took <B>0.05</B> > > seconds.</FONT></TD></TR> > > > > 2- <TD noWrap align=right bgColor=#3366cc><FONT color=#ffffff > > size=-1>Results <B>1</B> - <B>7</B> of about <B>10</B>. Search took > > <B>0.08</B> seconds.</FONT> > > > > Where the numbers will always change. > > I'm trying to extract the third number (*2* in example 1, *10* in example 2) > > > > I have this routine that only works with example 2 but not with example 1, > > how can I get it to work with both examples? > > > > $total = $line; > > $total = preg_replace("/^.*of about <b>/", "", $total); > > $total = preg_replace("/^.*of <b>/", "", $total); > > $total = preg_replace("/<.*$/", "", $total); > > $total = preg_replace("/\,/", "", $total); > > $total = trim($total); > > return($total); > > > > Or is there a better way? > > > > Thanks again. > > Mike > > > > > > > > --- > > Outgoing mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.493 / Virus Database: 292 - Release Date: 26/06/2003 > > > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.500 / Virus Database: 298 - Release Date: 2003-07-10 | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: help, preg_replace |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| Featured Websites | ||||
|