I'm picking up a .txt
file and removing the letters and lines in white. Tá giving problem with the special character \t
or \s
it does not recognize.
The code below:
<?php
function pass1() {
$treat = fopen ("C:\Users\Bridge\Downloads\D_lotfac\lott.txt", "r+w+");
$treat1 = fopen ("C:\Users\Bridge\Downloads\D_lotfac\lott1.txt", "r+w+");
while (!feof ($treat)) {
$linha = fgets($treat,4096);
$patterns = array();
$patterns [0] = '/[(A-Z)i]*/';
$patterns [1] = '/Â|Ã|Á|À|É|Ê|Í|Î|Ç|Ó|Õ|Ô|Ö|Ú|Û|Ü/';
$patterns [2] ='/ã|â|à|á|é|ê|í|î|ç|ó|ô|ô|ö|ú|û|ü/';
$patterns [3] = '/\t/';
$patterns [4] = '/[(a-z)i]*/';
$patterns [5] = ' ';
$replacements = array();
$replacements[] = '';
$linha = preg_replace($patterns, $replacements, $linha);
fwrite ($treat1, $linha);
printf($linha . "<br>");
}
}
You are generating the file lott1.txt
correctly, only tabs
is not being removed nor the spaces ( 2x
, 3x
, etc). I already put the tab literally "" or put \t
inside the $pattern[]
array. Does not delete.
What's the problem?