SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Extract images from array and store in variables

    Is there a simple way to extract 3 images from an array and store them into 3 different variables? Thanks.

    Maybe using list(), extract, foreach etc.
    PHP Code:
    foreach ($_FILES['image']['name'] as $number => $file) {

    $filenames[] = $file;
    }

    foreach(
    $filenames as $filename) {
        list(
    $a,$b,$c);

    Maybe I can just use this $filename[0], $filename[1], $filename[2]. I'll try an experiment.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Yes, you can use list. Read the manual, and you'll see how to use it

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks I will check that out.

    I seem to have figured it out doing this.

    $filenames[0], $filenames[1], $filenames[2].


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •