TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Match $var in text file ? (http://www.talkphp.com/general/4658-match-var-text-file.html)

Peuplarchie 07-01-2009 05:05 PM

Match $var in text file ?
 
Good day to you all,
stupid as it sound, all the thing that I have tried to match a variable into a text file and execute according to it result.


PHP Code:


$active 
"user_list.txt";
$pos strpos($active$_SESSION['username']);
if (
$pos === false) {
echo 
"<b id=\"userinfo\"><img src=\"enligne.png\" valign=\"bottom\" width=\"13px\"/></b>";
} else {
echo 
"<b id=\"userinfo\"><img src=\"horsligne.png\" valign=\"bottom\" width=\"13px\"/></b>";


Thanks !

Salathe 07-01-2009 06:14 PM

strpos will only act on strings, so your code is effectively looking for the username in the string user_list.txt and not in the contents of the file! You'll need to get the contents of the file (perhaps with the file_get_contents function) and then look for the username in those contents.


All times are GMT. The time now is 01:18 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0