I have an array $filenm that can hold one two or three image names. I am trying to extract those image names, put them into individual variables like $image01, $image02, $image03 and then insert them into a database.
How do I go about accomplishing this? I tried extract(), foreach(), and list() in an attempt to verify the image names in the array.
extract() echoed Warning: extract() : First argument should be an array
echoed $0 $1 $2
foreach() echoed Warning: Invalid argument supplied for foreach()
list() echoed the first three letters of the first image name.
If $filenm is an array with the filenames, you don’t need to extract the filenames to variables, you can just use foreach() to insert them in the DB one by one:
foreach($filenm as $filename) {
//SQL query, like INSERT INTO images_table (filename) VALUES ('$filename')
//don't forget to escape the values
}