PHP - Foreach in a foreach + CodeIgniter
        Posted  
        
            by 
                Sebhael
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sebhael
        
        
        
        Published on 2011-01-03T03:43:36Z
        Indexed on 
            2011/01/03
            3:53 UTC
        
        
        Read the original article
        Hit count: 706
        
I got an image upload function working, but there's 4 images required in this image. And my current function is simply just overwriting the image despite the number. I'm wondering how I would insert (preferably) a letter into my foreach function.
$uploads = array($this->uploads->data());
foreach ( $uploads as $key[] => $value )  
{
$imagename = $cleaned . '-s' . $value['file_ext']; //outputs clean-name-s.ext
}
By the time all is said and done, 4 images will require this function. Leaving me with clean-name-sa.ext, clean-name-sb.ext, clean-name-sc.ext, and clean-name-sd.ext (numbers work as well).
The form does require that all 4 fields are filled out before submission, so would I just create an array of my desired identifiers and create a foreach loop that outputs 4 different $imagenames? Or is there a simpler, more logical approach to this.
© Stack Overflow or respective owner