How to separate array by columns

Asked

Viewed 99 times

0

Good night!

I’d like to ask for your help on the following...

I need to read a txt, which contains information of a client x...

Only this txt is separated by lines and I n can change because it is a ready file of another program...

I need to separate this data and save it in a database... I was able to separate it into parts... but it stays like this:

Array ( [0] => 000145010730634CARLOS SILVA 0000015255 ) Array ( [0] => 0001 ) Array ( [0] => 00000102534 ) Array ( [0] => CARLOS SILVA ) Array ( [0] => 152,55 )

And I don’t know how to put those values in my bank.

I got that code right here:

$arquivo = $_FILES['arquivo'];

$arquivo_tmp = $_FILES['arquivo']['tmp_name'];

$dados = file($arquivo_tmp);

foreach ($dados as $linha) {

    $values = explode("\\r\\n|\\r|\\n", $linha);

    print_r($values);        

}

This code gives me that result...

Now I need to put that data on a table...

If you can help me.

I thank you from now on!

  • Put a sample of your text file

  • As you read the data in the foreach you add in the BD

  • has already managed to solve?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.