I have a text file of phone numbers like below:
+2348089219281 +2348081231580 +2347088911847 +2347082645764 +2348121718153 +2348126315930 +2348023646683.
I want to extract each number, strip +234
from it and replace with 0
, then add the following text "Names" . "\t"
in front of the modified number.
Then I want to insert this new string in a new text file (line-by-line).. This is what I get in the new_textFile with the code I've wrote:
Names 00urce id #3
Names 00urce id #3
Here's my code:
$this_crap_file = fopen($old_file_name, "r");
$total_number_lines_for_this_crap_file = count($this_crap_file);
while(!feof($this_crap_file))
{
$the_new_writing = fopen($new_file_name, "a");
$the_string = substr_replace($this_crap_file, "0", 0, 4);
$new_string = "Names" . "\t" . 0 . $the_string . "
";
fwrite($the_new_writing, $new_string);
}
fclose($this_crap_file);