Jump to content

Recommended Posts

Ok I have a file with my emails and passwords like this

 

email:pass

email:pass

email:pass

email:pass

 

and so on..

 

Is it possible to make a script that will delete everything after the ":" and replace the ":" with a comma?

 

Im not sure what functions or w/e I could use to make this possible?

Any ideas? Thanks

Link to comment
https://forums.phpfreaks.com/topic/212043-php-edit-file/
Share on other sites

So you want to get rid of the passwords in this file.

 

$filename = 'text.txt'; //name of your file.
$file = file($filename); //pull the file, and put it in an array.
foreach($file as $v) { //loop through the array.
list($email,$password) = explode(':',$v);  //split each row by the : assigning the variable $email before the colon, and $password after it.
$emails[] = $email . ','; //append a comma onto the end of  the email, and assign it to the emails array.
}
file_put_contents($filename,implode("\n",$emails));  //implode the data on a newline and send it back to the file, in OVERWRITE mode.

 

This will do it, although make sure you really want to, or at least make a copy of the original incase you want to reverse it.

Link to comment
https://forums.phpfreaks.com/topic/212043-php-edit-file/#findComment-1105044
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.