while loops
Moderators: Moderator, Global Moderator
while loops
[color=\"#000000\"]You\'re probably trying to confuse it a bit much. Try this: [code]<?php
$tnum = "Five";
$file = "Cups.txt";
$found = FALSE;
$desc = find_desc($tnum, $file);
echo $desc;
function find_desc($text, $file)
{
$lines = file($file);
foreach ($lines as $line_num => $line) {
$linenum = (int) $line_num;
$linenum++;
$t = strpos($line, $text);
if ($found === TRUE)
{
echo $line;
}
if($t !== false)
{
$found = TRUE;
}
}
}
?>[/code]
Not tested it, but it *should* work <img src=\'http://www.killanet.net/forum3/public/s ... unsure.gif\' class=\'bbc_emoticon\' alt=\':unsure:\' /> [/color]
$tnum = "Five";
$file = "Cups.txt";
$found = FALSE;
$desc = find_desc($tnum, $file);
echo $desc;
function find_desc($text, $file)
{
$lines = file($file);
foreach ($lines as $line_num => $line) {
$linenum = (int) $line_num;
$linenum++;
$t = strpos($line, $text);
if ($found === TRUE)
{
echo $line;
}
if($t !== false)
{
$found = TRUE;
}
}
}
?>[/code]
Not tested it, but it *should* work <img src=\'http://www.killanet.net/forum3/public/s ... unsure.gif\' class=\'bbc_emoticon\' alt=\':unsure:\' /> [/color]
Last edited by Scott on Mon Sep 26, 2005 3:34 pm, edited 1 time in total.
while loops
[color=\"green\"]err...that code returns the entire contents of the file <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' /> lol thanks anyway?[/color]
while loops
Ah, yeah. After echo $line; put $found = FALSE; That should stop it returning anything else.
while loops
Why are cups kept in a file? :\
while loops
[color=\"green\"]probably for the same reason that suits, swords and shields are...
that reason? nfi tbh <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />[/color]
that reason? nfi tbh <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />[/color]
while loops
[code]<?php
$tnum = "Five";
$file = "Cups.txt";
$desc = find_desc($tnum, $file);
echo $desc;
function find_desc($text, $file)
{
$found = FALSE;
$lines = file($file);
foreach ($lines as $line_num => $line) {
$linenum = (int) $line_num;
$linenum++;
$t = strpos($line, $text);
if ($found === TRUE)
{
echo $line;
return;
}
if($t !== false)
{
$found = TRUE;
}
}
}
?>[/code]
All workie. At least, thats what I think you\'re trying to do.
$tnum = "Five";
$file = "Cups.txt";
$desc = find_desc($tnum, $file);
echo $desc;
function find_desc($text, $file)
{
$found = FALSE;
$lines = file($file);
foreach ($lines as $line_num => $line) {
$linenum = (int) $line_num;
$linenum++;
$t = strpos($line, $text);
if ($found === TRUE)
{
echo $line;
return;
}
if($t !== false)
{
$found = TRUE;
}
}
}
?>[/code]
All workie. At least, thats what I think you\'re trying to do.
while loops
[color=\"green\"]...it still doesnt show anything <img src=\'http://www.killanet.net/forum3/public/s ... #>/cry.gif\' class=\'bbc_emoticon\' alt=\':(\' /> [/color]
while loops
Can I have a copy of the file please?
while loops
[color=\"green\"]Cups.txt? sure... [url=\"http://vercz.killanet.net/tst/Cups.txt\"]http://vercz.killanet.net/tst/Cups.txt[/url] =) [/color]
while loops
Ah...that makes sense. It is working, working too well. The script will print the line directly following the word \"Five\". Since your following line is a blank line...you see a blank line. Remove the empty lines and it\'ll work <img src=\'http://www.killanet.net/forum3/public/s ... /smile.gif\' class=\'bbc_emoticon\' alt=\':)\' />
while loops
[color=\"green\"]...im not stupid <img src=\'http://www.killanet.net/forum3/public/s ... el_not.gif\' class=\'bbc_emoticon\' alt=\'(not)\' />
thanks scott <img src=\'http://www.killanet.net/forum3/public/s ... iggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' /> and you too radar <img src=\'http://www.killanet.net/forum3/public/s ... iggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' /> <img src=\'http://www.killanet.net/forum3/public/s ... >/good.gif\' class=\'bbc_emoticon\' alt=\'(Y)\' /> <img src=\'http://www.killanet.net/forum3/public/s ... >/good.gif\' class=\'bbc_emoticon\' alt=\'(Y)\' /> [/color]
thanks scott <img src=\'http://www.killanet.net/forum3/public/s ... iggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' /> and you too radar <img src=\'http://www.killanet.net/forum3/public/s ... iggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' /> <img src=\'http://www.killanet.net/forum3/public/s ... >/good.gif\' class=\'bbc_emoticon\' alt=\'(Y)\' /> <img src=\'http://www.killanet.net/forum3/public/s ... >/good.gif\' class=\'bbc_emoticon\' alt=\'(Y)\' /> [/color]



