Re: Takeing a string and spliting it up.
| From: | Folke Ashberg | Date: | Sat, 25 Nov 2000 04:11:16 +0000 |
| Subject: | Re: Takeing a string and spliting it up. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27088@lists.php.net to get a copy of this message | ||
Hi!
What about this:
----
<?
$script = "
Spies<BR>
Troops<BR>
Jets<BR>
Turrets<BR>
Tanks<BR>
Nuclear Missiles<BR>
Chemical Missiles<BR>
EMD Missiles<BR>
<TD NOWRAP ALIGN=RIGHT><FONT COLOR=#FFEECC SIZE=-1>
0<BR>
401,096<BR>
771,923<BR>
552,269<BR>
103,164<BR>
1<BR>
3<BR>
1<BR>";
$lines=split("\n","$script\n");
reset ($lines);
$what=0;
$cnt=0;
while (list($key,$val)=each($lines)) {
if ($val) if (eregi("^<TD.*",$val)) { $cnt=0; $what=1;}
else {$weapons[$cnt][$what]=strip_tags($val); $cnt++;}
}
reset ($weapons);
while (list($key,$val)=each($weapons)) {
print "$val[0]: $val[1]<BR>\n";
}
?>
-----
output:
Spies: 0
Troops: 401,096
Jets: 771,923
Turrets: 552,269
Tanks: 103,164
Nuclear Missiles: 1
Chemical Missiles: 3
EMD Missiles: 1
OK? -> Nice war!
regards
Folke
--
Folke Ashberg
Stage Internet Services GmbH
Technical Development
folke@fanstage.de
folke@fanstage.de | Tel: +49 89 454591-77 | Fax: +49 89 454591-71
Kreillerstr. 21 | 81673 Munich | Germany | www.fanstage.de
On Sat, 25 Nov 2000, Folke Ashberg wrote:
> Question:
> from the beginning up the the line starting with <TD once per line you
> have all your nice weapons listed, then once per line the amount of the
> sum you have.
>
> Then i can form the few lines src for you
>
> Folke
>
>