Kim Jensen wrote:
> while (list ($key, $val) = each ($list)) {
> echo "<a href=test.php?name=$val>$val</a><br>";
>
> }
>
> Here I'd like the $val after the name= to be just the filename without
> the extention (all files in the directory are txt files)
echo '<a href="test.php?name=', substr($val, -4), ">$val</a><br";
> and then the
> second $val which it shows in the list to be the value of the line
> charname= in the txt files themselves.
Are you really sure you want to do that?
You have top open each and every file, read/print its contents, and close
the file. It might be a lot slow!
/* needs error-checking for fopen() and fgets() */
foreach ($list as $val) {
$f = fopen($val);
while (!feof(f)) {
$line = fgets($f);
if (preg_match('/^charname=(.*)$/', $line, $matches)) {
echo '<a href="test.php?name=', urlencode(substr($val, -4)),
'">', $matches[1], '</a><br>';
break; /* leave inner while() */
}
}
fclose($f);
}
--
Mail sent to my "From:" address is publicly readable at
http://www.dodgeit.com/
== ** ## !! !! ## ** ==
TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may
bypass the spam filter. I will answer all pertinent mails from a valid address.