explode the array into string with line breaks seperation and put everthing back in the fileįile_put_contents('toApprove.txt', implode("\n", $Array)) assuming unique values, lets remove the Array key with value $_GET Or // retrieve the file into an array where each line is a value replace the line with $_GET, assuming line break is \n $txt = file_get_contents('toApprove.txt') If you are working with small files, you could save time by doing something like: // retrieve file into a string Your code is very good for file updates as it is very memory efficient. Databases are very efficient at this though by design. The database then does basically what you are doing with the files, on the disk or memory depending on the storage type being used. It is much simpler than having to read/write from files.įor example, with a DB it is as simple as: $result = $Db->Query("DELETE FROM `table` WHERE `column` = '".mysql_real_escape_string($_GET) Normally, you'd want to have a database do this job for you. Is there an error you're getting? I don't see any particular problem in the code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |