$file = file($commentfile); // Reads file
$disstr = substr($file, 31, 6); // returns "FFFFFF"
echo $disstr;
in $commentfile all 15 lines of the *messages* from the shoutbox are stored.
$file opens that file and reads it right? It reads the first line? If not how can I make it so?
31 is when it gets right next to the FFFFFF which is the bgcolor. If i make file equal ...
<tr><td cellpadding=0 bgcolor=#FFFFFF>
It will work but doesnt display anything when i actually run it the real way.
Substr
Moderator: General Moderators
Not that different if I may add a personal comment. I did this when learning php, and it's really just read file into array, add a string to the array, re-write the file.
Each line contained string like: JAM|date|text that I exploded into usable variables, then echo them in a loop.
I made the str_len of the text <50 chars long, and the file automaticly discarded all lines above 20, so the textfile I used never got extremely large (main reason to use a db-shoutbox).
Each line contained string like: JAM|date|text that I exploded into usable variables, then echo them in a loop.
I made the str_len of the text <50 chars long, and the file automaticly discarded all lines above 20, so the textfile I used never got extremely large (main reason to use a db-shoutbox).
Hey, long time no post here. I moved to another country and didn have any net access. I just installed RedHat so no mysql was compiled there. I was forced to use a flat file as a database - imagine the horror!
Anyhow, it's fairly simple. No more fopen() needed imho. Just use file(). Writing, fopen("file", "a+") and it works like a breeze
. So don't be scared to explore.
I tried exploring XML but then that wasn't sooo successful
-Nay
Anyhow, it's fairly simple. No more fopen() needed imho. Just use file(). Writing, fopen("file", "a+") and it works like a breeze
I tried exploring XML but then that wasn't sooo successful
-Nay
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
ahhhh yes. the Mac has landed
. There's a huge book store just 15 minutes away from my house (Kinokuniya, ever heard of it?). I go there everyday to read a book about XML and stuff and still a little :S. Just that every time i look at a XML parsing code in php (wow, 3 - 4 pages) and i just close the book and run away.
mMm...............i really need to stop doing that!
-Nay
mMm...............i really need to stop doing that!
-Nay
Yeah I got a 900 page book on PHP and XML that I'm just about half way done with reading. I have yet to do any execution or practice for the things i've read so far, thought it seems pretty practical and simple.
I've built so many things with a MySQL database since my newbie days that I've almost totally ignored other types of storage and data management methods.

I've built so many things with a MySQL database since my newbie days that I've almost totally ignored other types of storage and data management methods.