![]() |
|
[PHP] PHP Cursor Positioning - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [PHP] PHP Cursor Positioning (/showthread.php?tid=5959330) |
PHP Cursor Positioning - Jack Drake - Apr 11, 2019 I was wondering if there was a way to move the cursor after opening a file using: Code fopen("file", "a");Such that the cursor is two lines up. RE: PHP Cursor Positioning - Squito - Apr 11, 2019 PHP Code RE: PHP Cursor Positioning - Jack Drake - Apr 11, 2019 Thanks a lot, but unfortunately it didnt work. RE: PHP Cursor Positioning - ChaoticHaze - Apr 11, 2019 (Apr 11, 2019 01:48 PM)Jack Drake Wrote: Thanks a lot, but unfortunately it didnt work. I guess what you want is that lines are always being added on top of file. That you can achieve like this: PHP Code RE: PHP Cursor Positioning - Jack Drake - Apr 11, 2019 The issue is that the file everything is appended from the bottom and it needs to be above the first bracket for json. RE: PHP Cursor Positioning - ChaoticHaze - Apr 11, 2019 (Apr 11, 2019 02:05 PM)Jack Drake Wrote: The issue is that the file everything is appended from the bottom and it needs to be above the first bracket for json. You should show us some more code to be able to help you properly. RE: PHP Cursor Positioning - Jack Drake - Apr 11, 2019 The file is in json and it has information that can't be posted here, but the php file is appending information into the file. Now, the issue is that when whenever i append data it adds it into the file at the end Code {It doesn't put the info inside the curly braces, so that's why I want to move the cursor up 2 lines to append it there. RE: PHP Cursor Positioning - newQuery - Apr 12, 2019 (Apr 11, 2019 04:09 PM)Jack Drake Wrote: The file is in json and it has information that can't be posted here, but the php file is appending information into the file. Now, the issue is that when whenever i append data it adds it into the file at the end First retrieve the content of your file (file_get_contents) & store it in a variable ($content) json_decode its value, add your wanted datas to your array json_encode & put the content back to it's file. PHP Code RE: PHP Cursor Positioning - Jack Drake - Apr 14, 2019 Thanks a lot it worked out when i got the file content. |