$fp=fopen("somefile.txt","rw"); $idnumber=fread($fp,filesize("somefile.txt"))+1; fwrite($fp,$idnumber); fclose($fp);