Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

77 users online



Failing To Increment:

Failing To Increment:

Currently viewing this thread: 1 (0 members and 1 guests)


vvuiverine

vvuiverine

Status: Offline!

Failing To Increment:

Why is the folling code failing to increment:

$file = file("2test.dat");
$fp = fopen("2test.dat","w");
$inc = ++$file[0];
fwrite($fp,$inc);
echo $file[0];

for some reason it will only work on one file. Also, I'm on windows so file permissions are not the problem

Last edited by vvuiverine, October 17th, 2002 02:59 AM (Edited 1 times)

kobs

kobs

Lost in Hollywood
Status: Offline!

i think it's supposed to be

$file[0]++

___________________

"The man who makes no mistakes does not usually make anything." - Edward J. Phelps

bryan

bryan

Neversidian
Status: Offline!

If that doesn't work, try incrementing $file[0], and then setting $inc to the new value. I don't think it matters if the ++ goes before or after the variable.

___________________

Mugging Scotty Good.
www.muggingscotty.com

CDude

CDude

nothing
Status: Offline!

$file = file("2test.dat"); <-- OK
$fp = fopen("2test.dat","w"); <-- open file, then clear any content
$inc = ++$file[0]; <-- where is this array from?? $file is not an array, it is a file pointer. it points to 2test.dat
fwrite($fp,$inc);
echo $file[0];

nevermind, i'm an idiot. i didn't see that file()

$file[0]++; should work

$inc = $file[0]++;
fwrite($fp,$inc);
echo $inc;

___________________

http://celerondude.com

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0163 seconds.