TheJoey Posted September 22, 2009 Share Posted September 22, 2009 ive got this script which shows the two files joined. althought it displays it wrong. text dsf sdf sd fs df sd f sdf s df sd text1 mo||67||joe||joe joe||67|||| this is the code that joins them both <?php $joined = file_get_contents('users.txt') . file_get_contents('data.txt'). "\r\n"; echo $joined; ?> and it is being displayed this way dsf sdf sd fs df sd f sdf s df sdmo||67||joe||joe joe||67|||| Quote Link to comment https://forums.phpfreaks.com/topic/175072-joining-two-txt-files/ Share on other sites More sharing options...
Garethp Posted September 22, 2009 Share Posted September 22, 2009 echo nl2br($joined); Quote Link to comment https://forums.phpfreaks.com/topic/175072-joining-two-txt-files/#findComment-922686 Share on other sites More sharing options...
TheJoey Posted September 22, 2009 Author Share Posted September 22, 2009 that just displays them after each other is there a way where i can join both first lines? Quote Link to comment https://forums.phpfreaks.com/topic/175072-joining-two-txt-files/#findComment-922688 Share on other sites More sharing options...
Garethp Posted September 22, 2009 Share Posted September 22, 2009 $joined = ""; $File1 = file('text.txt'); $File2 = file('text1.txt'); foreach($File1 as $k=>$v) { $joined .= $v . $File2[$k] . "<br>"; } echo $joined; Quote Link to comment https://forums.phpfreaks.com/topic/175072-joining-two-txt-files/#findComment-922695 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.