Save items from array on mysql with php
Hi i have one situation and i dont know what exactly i need to do.
This is a multiple file upload so im doing this
$files = $_POST["files-temp"];
this return ( iten1.jpg;iten2.jpg;iten3.jpg;) there is a semicolon on last iten
then i did
$array = preg_split('/;/',$files);
then i got
Array ( [0] => iten1.jpg [1] => iten2.jpg [2] => iten3.jpg [3] => )
So there is a iten 4 that not exists, so i need to find a better way to do this then count and execut the query to save on mysql.
thanks for any help.
Answer
Solution:
If
$files
contains a string and want to remove that last extra array location:Try:
Test Here