BRADERY Posted November 17, 2010 Share Posted November 17, 2010 <?php $filename = "text.txt"; $filename2 = "text2.txt"; $file = file($filename, FILE_SKIP_EMPTY_LINES); foreach($file as $cwb) { $ids[] = "\$id_to_save[] = ".$cwb.";"; } file_put_contents($filename2,implode($ids,"\n\r")); ?> it takes ids from a file and implodes to a new file its supposed to looked like this $id_to_save[] = id; $id_to_save[] = id; $id_to_save[] = id; $id_to_save[] = id; instead it turns out like this $id_to_save[] = 4234324 ; $id_to_save[] = 2342343 ; $id_to_save[] = 3423432 ; $id_to_save[] = 3243244; I've tried trim() but it hasnt seemed to work., any help is appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
mikecampbell Posted November 17, 2010 Share Posted November 17, 2010 Was this how you were using trim? foreach($file as $cwb) { $cwb = trim($cwb, " \n\r\0"); $ids[] = "\$id_to_save[] = ".$cwb.";"; } Quote Link to comment 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.