1
How do I remove spaces from a text file? I have the following text file:
LC1 00019 1 31012012 00001 00243206
I uploaded and put the following code:
$abrirArquivo = fopen($uploadArquivo, "r");
while(!feof($abrirArquivo)){
$ler = fgets($abrirArquivo,460);
$quebrar = explode(" ",trim($ler));
print_r($quebrar)."<br>";
}
fclose($abrirArquivo);
But when I gave a print_r()
, appeared that way:
Array ( [0] => LC1 [1] => 00001 [2] => [3] => [4] => 1 [5] => 31012012 [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 00001
Note that many keys have gone without values. How do I solve this problem?
How do you want to read the string? pq explodes it by space?
– rray
I actually need to get just some information from this text file. For example: I need 31012012 and 00243206. I blew up to break and pick up inside an array, but I’m running into this challenge.
– user24136
You can use the ID number,
3
and5
, ex,echo $quebra[3] .'#'. $quebra[5];
is continuation of that?– rray
I’m sorry, I don’t understand your question...
– user24136