Wednesday 15 June 2011

fopen - Set limits for add content in text file with PHP -


I need to create a list of the members of the last log in my website, but I do not want user MySQL I Stackoverflow and Google and this code is written:

  /////////// Check LIMIT $ Collection = "engine / data / type.txt"; $ Readz = file_get_contents ($ archive); $ Listz = explosion ('||' ', $ readz); $ Counter = count ($ listz); If ($ counter> "3") {$ stop = "1"; } And {$ stop = "0"; } If (if you are available) (preg_match ("& lt;! - UserID: {$ member_id} ->", $ readz) / {$ content = file_get_contents} ($ Warehouse); $ Content = str_replace ("& lt;! - UserID: {$ member_id} - & gt;". $ User. "|||", '', $ content); File_put_contents ($ archive, $ content); } // ADD member then if (! Preg_match ("& lt;! - User ID: {$ member_id} ->", $ readz)) {$ beonline_file = fopen ($ archive, "A +"); Fwrite ($ beonline_file, "& lt;! - User ID: {$ member_id} - & gt;". $ User. "|||"); Fclose ($ beonline_file); }}   

The problem is that I can not set the limits! How can I edit this code to set the limit for adding 20 users to a text file?

Maybe you can?

  if (! Preg_match ("& lt;! - UserID: {$ member_id} ->", $ readz)) {$ nlistz = explosion ('||' ', $ Readz); If (count ($ nlistz) == 20) {array_shift ($ nlistz); $ Newlistz = implode ("|||", $ nlistz); $ Beonline_file = fopen ($ archive, "w +"); Fwrite ($ beonline_file, $ newlistz. "||| & lt ;! - User ID: {$ member_id} - & gt;". $ User. "|||"); Fclose ($ beonline_file); } And {$ beonline_file = fopen ($ archiving, "a +"); Fwrite ($ beonline_file, "& lt;! - User ID: {$ member_id} - & gt;". $ User. "|||"); Fclose ($ beonline_file); }}    

No comments:

Post a Comment