Jump to content

Extract 2 Variables from a text file


Azaz

Recommended Posts

For example:

 

I am using this code:

 

$myFile = "newuser.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, 5);
fclose($fh);
echo $theData;

 

and it displays:

 

 Bob 2 

Which I am reading from my newuser.txt file!

 

Which corresponds to the username bob, and he has the ID of 2.

 

Now I want to make that linkable like this:

 

<a href=.?act=Profile&id=$IDFROMTEXTFILE(2)>$NAMEFROMTEXTFILE(BOB)</a>

 

this is possible? If so, Thanks!

Link to comment
https://forums.phpfreaks.com/topic/209333-extract-2-variables-from-a-text-file/
Share on other sites

$myFile = "newuser.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, 5);
fclose($fh);
$pices=explode(' ', $theData);
echo "<a href=\".?act=Profile&id=$pices[1]\">$pices[0]</a>";

 

Thanks!!

 

But my id has more then 1 character it currently only shows 1 digit from my 2digit id any cause why?

 

My id is 73, it only shows 7 hmm?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.