hi guys
i have a problem here it seems like i dont get a solution.i manage to write to the text file but i want to update the existing line without writting a new line.
my problem is when i want to append at the end of a line my programm write at the beginning of a next line.
example
1 (2008_22)-simon; thuli ; tumi
2 (2008_23)-dude ; dan ;
3 dan;tumu(2008_2 4) -danken ;bobo;
my problem is i want to add : dan and tumi at the end of the second line
not at the begining of the third line.
someone look at my code and help: - function write($lineNumbers,$lineNumber)
-
{
-
if($_POST["cite1"] && $_POST["cite2"] && $_POST["cite3"])
-
$data =$_POST["cite1"].";" .$_POST["cite2"].";".$_POST["cite3"];
-
-
$q=$_POST["path"];
-
-
$myArray = file($q."Registry.txt");
-
//echo "the linenumber is ".$lineNumbers." the line is ". $myArray[$lineNumbers-1]."<br/>";
-
-
//Open registry file and wipe contents
-
-
$fp = fopen($q."Registry.txt", "w");
-
//$myArray[$lineNumbers-1] = $myArray[$lineNumbers-1].$data;
-
//echo $myArray[$lineNumbers-1]."<br />";
-
$newdata = $myArray[$lineNumbers-1].$data;
-
//echo $newdata."<br/>";
-
-
// remove the line from a file
-
unset($myArray["$lineNumbers-1"]);
-
// put the data at the end of my file
-
array_push("$myArray","$newdata");
-
-
usort($myArray,"strnatcmp");
-
-
//Loop through the registry array
-
-
foreach ($myArray as $value)
-
-
{
-
-
//Write the sorted contents to registry line-by-line
-
-
fwrite($fp,$value);
-
-
-
-
}
-
-
-
-
// Close the registry file
-
-
fclose($fp);
-
echo "the registry updated successfully <br />";
-
$myArray1 = file($q."Registry.txt");
-
echo "new registry is ".$myArray1[$lineNumbers-1]."<br />";
-
echo "line after is ".$myArray1[$lineNumbers]."<br />";
-
-
}
-
-
-
-
-
-
?>
1 1203
PHP should be like C++, where you can make a while loop then get something like fgets into the while loop and count for each line into a int and get the lines into a string array and if you want to replace a certain line just enter,
array[$iLine--] = "My data goes here."; = Line1, so just minus the id number by one.
For removel just make the line equal nothing in double quotes and make a if statment weather if that line has something or not to break the line or not or even enter the text.
Then get all the arrays representing the line and print them back out into the file like new into each line using that if statment.
I wanted to be a bit of a help, but that should give you a idea what to do.
BTW use the PHP tags please! So its easier to read your code. Its that button with the php page uptop in the editor.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: flupke |
last post by:
Hi,
i'm having trouble with deleting elements from a list in a for loop
============== test program ==============
el =
print "**** Start ****"
print "List = %s " % el
index = 0
for line in el:
|
by: Dan |
last post by:
hello,
I would to know if it is possible to delete an instance in an array, The
following does not allow me to do a delete.
I am trying to find and delete the duplicate in an array, thanks
for ( j =0; j<MAX ; j++)
{
for ( i =0; i<MAX ; i++)
|
by: Bandit |
last post by:
I'm populating a gridview (called docList) with document info from a
network folder like so:
Sub Show_Files(ByVal inputDir As String)
Dim strFileNamePath As String = inputDir
Dim dirInfo As DirectoryInfo = New DirectoryInfo(strFileNamePath)
Dim aFiles As FileInfo() = dirInfo.GetFiles("*.doc")
Array.Sort(aFiles, New CompareFileInfoEntries
(CompareByOptions.LastWriteTime))
docList.DataSource = aFiles
|
by: DP |
last post by:
hi,
i've got a form, with a subform in it. i've got a delete button in the
subform. the code i;ve got is;
Private Sub cmdDeleteRecord_Click()
msg = "Are you sure you want to delete this film rental record?"
Style = vbYesNo + vbQuestion + vbDefaultButton2
|
by: programming |
last post by:
how do i delete from a text file 1 of the following lines:
jon|scott
adam|smith <--delete
paul|clark
say i would like to delete the middle line of this txt, in member.txt
what php code or logic would help me accomplish this?
| |
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= |
last post by:
One more for today....
As I add more and more lines to my RichTextBox the array that holds its
strings gets bigger and bigger and the vertical scroll bar gets smaller and
smaller until the string array finally runs out of memory. I'd like to set
some line limit and once that limit is reached, start removing the first line
each time a new line is appended onto the end. I think this is probably more
of an array manipulation question than...
|
by: n00b |
last post by:
Hello everyone, I just had a question about deleting objects in C#.
For example if I have a string array and I wanted to make it grow by one size adding the string "dd" to it.
string array = new string {"aa", "bb", "cc"};
string temp = array;
array = new string;
array = "dd";
|
by: helraizer1 |
last post by:
Hi folks,
I have a file for my chatbox called data.line, which the posts are in the layout
CHATBOXTEXT
7
username=helraizer
1202416953
|
by: Faisal Shah |
last post by:
HI,
Well, Here is the code of my new project .. Actually it's just s scrap or it..
I have made 2 files.
the 1st file is test.php with of course creating a new file called testdb.txt.
And the file called admin.php
here is the code.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |