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:
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:
Code:
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 />";
}
?>
Comment