php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67218 fwrite row from an other file
Submitted: 2014-05-06 14:55 UTC Modified: 2014-05-06 15:42 UTC
From: sebrsu at gmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: Irrelevant OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sebrsu at gmail dot com
New email:
PHP Version: OS:

 

 [2014-05-06 14:55 UTC] sebrsu at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.echo
---
<?php

$file1 = "test.txt";
$file2  = fopen("out.inc","a");

$rows = file($file1);  
      
foreach($rows as $key => $row)  
       {  
       echo $row;  
	   $rowhtml = "<tr>".$row."</tr>";
	   fwrite($file2, $rowhtml);
	   
       } ; 


fclose($file2);




What is the criteria of writing $rowhtml ? Random criteria ? How that it works the carriage return ?




Test script:
---------------
In file test.txt there is:

12345678
90abcdef
ghil

Function echo response:

12345678 90abcdef ghil 

In file out.inc:
<tr>12345678
</tr><tr>90abcdef
</tr><tr>ghil
</tr>



Expected result:
----------------
In file out.inc:

<tr>12345678</tr>
<tr>90abcdef</tr>
<tr>ghil</tr>


Actual result:
--------------
In file out.inc:
<tr>12345678
</tr><tr>90abcdef
</tr><tr>ghil
</tr>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-05-06 15:42 UTC] johannes@php.net
-Status: Open +Status: Not a bug
 [2014-05-06 15:42 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

See http://php.net/file and the reference to FILE_IGNORE_NEW_LINES
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 01:01:35 2025 UTC