Separate array in php

Asked

Viewed 56 times

1

Guys I’m trying to separate the array but it all comes together in this way fernandohenriquelopes I wanted to separate them so I can make multiple Insert in the bank the code is like this

// aqui recebe em array 

$dad = filter_input(INPUT_POST, 'tituloFoto', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); 

foreach ($dad as $id => $titulos) {

$re = array( ++$id => $titulos);

print_r($re); // desta forma sai normal 

//Array ( [1] => fernadno ) Array ( [2] => rafael ) Array ( [3] => yeyeye )

// se eu tirar o print_r fica assim
Notice: Array to string conversion in C:\xampp\htdocs\arte-beleza\galeria-gravar.php on line 21
Array (3x)
    }

When I write to the database it only shows array 3 times someone helps me?

  • You want to make multiple Inserts of each item from Array returned to print_r ?

  • this friend but I managed to solve. Where can I put the result of how I did?

  • You can put it right here as a response and mark it as solved.

  • you can use serialize in the array to save to the database and unserialize to recover from the database, so the array is saved in string form and retrieved in array form, without losing the keys you defined.

  • 1

    @Brunofolle liked this idea I will test. Even if I have already solved it is good that learning new things

No answers

Browser other questions tagged

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