Tengo un código fuente como este:
<?php if(isset($_POST['text_boxx'])) { $aa = $_POST['text_boxx']; $myFilee = "./SCENARIO/ocstesting-aktif.txt"; $fhh = fopen($myFilee, 'w') or die("can't open file"); fwrite($fhh,$aa); fclose($fhh); } if(isset($myFilee)){ $myFilee2 = "./SCENARIO/ocstesting.txt"; $fhh2 = fopen($myFilee2, 'w') or die("can't open file"); $filer = file('./SCENARIO/ocstesting-aktif.txt'); foreach ($filer as $file_num => $fileline){ $aaa="{$file_num}. Hello my name is: " . $fileline . " hoho \n"; fwrite($fhh2,$aaa); } fclose($fhh2); } ?>si ingreso en el cuadro de texto:
Oki DitoQuiero que aparezca en la web como:
0. Hello my name is Oki hoho 1. Hello my name is Dito hohopero aparece:
0. Hello my name is: Oki hoho 1. Hello my name is: Dito hohoPor favor, alguien puede ayudar :( ? Gracias
deberías escribir esta línea de la siguiente manera
$aaa="{$file_num}. Hello my name is " . $fileline . " hoho \n";Simplemente omita el : después de es.
La función de archivo devuelve una matriz con el final de línea: consulte la documentación
2 soluciones:
FILE_IGNORE_NEW_LINESrtrim en tu $fileline