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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 09:01:30 2024 UTC