motormichael12
07-27-2008, 03:29 AM
I am using this code right here:
<?php
@$tribes = gzfile('http://en7.tribalwars.net/map/ally.txt.gz');
if(!is_array($tribes)) die("Tribe file could not be opened");
$list = $_POST['list'];
$list = trim(str_replace("\tterminate", "", $list));
$list = explode("\n", $list);
$hmmm = array();
/*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//for($i=0;$i<count($list);$i++)
//{
foreach($tribes as $each_tribe) {
list($id, $name, $tag, $members, $villages, $points, $all_points, $rank) = explode(',', $each_tribe);
$name = urldecode($name);
foreach($each_tribe as $each_tribe2){
echo $each_tribe2;
//$name = addslashes($name);
if($tag == $each_tribe2){
echo $hmmm . $id . "<br>" . $name . "<br>" . $tag . "<br>" . $members . "<br>" . $villages . "<br>" . $points . "<br>" . $all_points . "<br>" . $rank . "<br><br>";
}
}
}
*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
foreach ($list as $tempone) {
foreach ($tribes as $each_tribe) {
list($id, $name, $tag, $members, $villages, $points, $all_points, $rank) = explode(',', $each_tribe);
//echo "$tempone: $tag", "<br>";
if($tag == $tempone){
echo $id . "<br>" . $name . "<br>" . $tag . "<br>" . $members . "<br>" . $villages . "<br>" . $points . "<br>" . $all_points . "<br>" . $rank . "<br><br>";
}
}
echo "\n";
}
*/
for($a=0;$a<count($tribes);$a++){
list($id, $name, $tag, $members, $villages, $points, $all_points, $rank) = explode(',', $tribes[$a]);
for($i=0;$i<count($list);$i++){
if($tag == $list[$i]){
echo $id . "<br>" . $name . "<br>" . $tag . "<br>" . $members . "<br>" . $villages . "<br>" . $points . "<br>" . $all_points . "<br>" . $rank . "<br><br>";
}
}
}
echo "<BR><BR><BR>";
?>
<form name="input" action="t.php"
method="post">
<textarea ROWS=30 COLS=30 NAME="list"><?php for($i=0;$i<count($list);$i++){echo $list[$i]."\n";} ?></textarea>
<input type="submit" value="Submit">
</form>
The gzip file (http://en7.tribalwars.net/map/ally.txt.gz) is also located at http://en7.tribalwars.net/map/ally.txt, and it is a small file. It can be loaded very quickly if anyone wants to look at it.
I know this isn't exactly a clean code but at the moment I can't get it to work. All the commented foreach/for loops are previous attempts. The gzfile looks like this:
14006,Gladiator,Glad,18,0,0,0,413
15048,Retaliation,RET,1,2,570,570,301
45,Pure+Renegade+Soldiers+Academy,PRS-A,116,518,1695403,2477457,60
18432,Car+Stefan+Dusan+Silni,CSDS,20,355,2895261,2895261,49
150,-LTU-,-LTU-,1,11,11926,11926,153
36766,meklar+beta,mek+b,5,5,3198,3198,197
36699,REF+fanclub,REF+0,1,1,895,895,279
27818,Alliance+of+the+Knight,AOTK,1,1,923,923,276
16441,MASTER+HEROES,MH,31,38,68242,68242,101
8745,Knights+of+Oblivion,%3DKO%3D,1,1,422,422,317
I have tried entering the following in the textbox (at the same time, it is one entered data set):
Meklar
Tribal Fluffy Bunnies
T.F.B.
T.F.B.
T.F.B. is the tag for Tribal Fluffy Bunnies, and Meklar's name and tag are both Meklar. All data entered exists, but it only prints the data for the last result. Therefore, in this example it would print hte data for T.F.B., like this.
15358
Tribal+Fluffy+Bunnies
T.F.B.
54
10372
98521330
105316064
1
However, here is anotehr data/result set:
Meklar
Tribal Fluffy Bunnies
T.F.B.
T.F.B.
Meklar
6425
Meklar
Meklar
91
832
5257190
5670780
38
I need it to print the data for each match. How do I do this?
Any help is greatly appreciated, and sorry for so much to read through but I try to be detailed.
<?php
@$tribes = gzfile('http://en7.tribalwars.net/map/ally.txt.gz');
if(!is_array($tribes)) die("Tribe file could not be opened");
$list = $_POST['list'];
$list = trim(str_replace("\tterminate", "", $list));
$list = explode("\n", $list);
$hmmm = array();
/*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//for($i=0;$i<count($list);$i++)
//{
foreach($tribes as $each_tribe) {
list($id, $name, $tag, $members, $villages, $points, $all_points, $rank) = explode(',', $each_tribe);
$name = urldecode($name);
foreach($each_tribe as $each_tribe2){
echo $each_tribe2;
//$name = addslashes($name);
if($tag == $each_tribe2){
echo $hmmm . $id . "<br>" . $name . "<br>" . $tag . "<br>" . $members . "<br>" . $villages . "<br>" . $points . "<br>" . $all_points . "<br>" . $rank . "<br><br>";
}
}
}
*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
foreach ($list as $tempone) {
foreach ($tribes as $each_tribe) {
list($id, $name, $tag, $members, $villages, $points, $all_points, $rank) = explode(',', $each_tribe);
//echo "$tempone: $tag", "<br>";
if($tag == $tempone){
echo $id . "<br>" . $name . "<br>" . $tag . "<br>" . $members . "<br>" . $villages . "<br>" . $points . "<br>" . $all_points . "<br>" . $rank . "<br><br>";
}
}
echo "\n";
}
*/
for($a=0;$a<count($tribes);$a++){
list($id, $name, $tag, $members, $villages, $points, $all_points, $rank) = explode(',', $tribes[$a]);
for($i=0;$i<count($list);$i++){
if($tag == $list[$i]){
echo $id . "<br>" . $name . "<br>" . $tag . "<br>" . $members . "<br>" . $villages . "<br>" . $points . "<br>" . $all_points . "<br>" . $rank . "<br><br>";
}
}
}
echo "<BR><BR><BR>";
?>
<form name="input" action="t.php"
method="post">
<textarea ROWS=30 COLS=30 NAME="list"><?php for($i=0;$i<count($list);$i++){echo $list[$i]."\n";} ?></textarea>
<input type="submit" value="Submit">
</form>
The gzip file (http://en7.tribalwars.net/map/ally.txt.gz) is also located at http://en7.tribalwars.net/map/ally.txt, and it is a small file. It can be loaded very quickly if anyone wants to look at it.
I know this isn't exactly a clean code but at the moment I can't get it to work. All the commented foreach/for loops are previous attempts. The gzfile looks like this:
14006,Gladiator,Glad,18,0,0,0,413
15048,Retaliation,RET,1,2,570,570,301
45,Pure+Renegade+Soldiers+Academy,PRS-A,116,518,1695403,2477457,60
18432,Car+Stefan+Dusan+Silni,CSDS,20,355,2895261,2895261,49
150,-LTU-,-LTU-,1,11,11926,11926,153
36766,meklar+beta,mek+b,5,5,3198,3198,197
36699,REF+fanclub,REF+0,1,1,895,895,279
27818,Alliance+of+the+Knight,AOTK,1,1,923,923,276
16441,MASTER+HEROES,MH,31,38,68242,68242,101
8745,Knights+of+Oblivion,%3DKO%3D,1,1,422,422,317
I have tried entering the following in the textbox (at the same time, it is one entered data set):
Meklar
Tribal Fluffy Bunnies
T.F.B.
T.F.B.
T.F.B. is the tag for Tribal Fluffy Bunnies, and Meklar's name and tag are both Meklar. All data entered exists, but it only prints the data for the last result. Therefore, in this example it would print hte data for T.F.B., like this.
15358
Tribal+Fluffy+Bunnies
T.F.B.
54
10372
98521330
105316064
1
However, here is anotehr data/result set:
Meklar
Tribal Fluffy Bunnies
T.F.B.
T.F.B.
Meklar
6425
Meklar
Meklar
91
832
5257190
5670780
38
I need it to print the data for each match. How do I do this?
Any help is greatly appreciated, and sorry for so much to read through but I try to be detailed.