Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:46:59+00:00 2026-05-30T17:46:59+00:00

I am trying to get images from while loop and split them up at

  • 0

I am trying to get images from while loop and split them up at the period (.).. and then change the name of the image to ImageName + -resized. But I can not seem to figure out how to do this. Any help would be greatly appreciated!

So in short I have this: image.jpg and I want to create this image-resized.jpg: Here is my code:

<?php 
    $f = $_GET['f'];
    $h = $_GET['h'];
    $gp = $_GET['gp'];
    //Create folder path
    $path = "Fotos/".$f."/".$h."/".$gp."/";
    //Get pictures from database
    $getfolders = mysql_query("SELECT FolderName, Files FROM Files WHERE FolderDate = '$f' AND FolderHour = '$h' AND FolderName = '$gp'") or die(mysql_error());
    //List pictures from database
    while($row = mysql_fetch_array($getfolders)){
        $img = $row['Files'];
        //Seperate image at period(.)
        $image = explode('.', $img);
        //Get image name ----------------Here is where I need help!!
        for($i = 0; $i < sizeof($image); $i++)
          {
          $imag = $image[$i];
          }
        ?>
    <div class="picture" id="pic"><img src="<?php echo $path; echo $imag ?>" alt="picture" /><?php echo $img?></div>
        <?php
        }
    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:47:00+00:00Added an answer on May 30, 2026 at 5:47 pm

    Well, the simplest solution would be:

    $image = explode('.', $img);
    $extension = array_pop($image);
    $resizedFileName = implode('.', $image) . "-resized.{$extension}";
    

    But this solution does assume, that there are only simple extensions:

    image.jpg => image-resized.jpg // ok
    image.tar.gz => image.tar-resized.gz // not so ok
    

    But if there are only simple extensions, this solution might be sufficient.

    A better solution would be using SplFileInfo:

    $fi = new SplFileInfo($image);
    $resizedFileName = $fi->getBasename("." . $fi->getExtension()) . "-resized." . $fi->getExtension();
    

    SplFileInfo::getExtensions() is available since PHP 5.3.6

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get an image from an HTTP server using Perl. I
I'm trying to get the pixel information from an image and have got to
I trying to use ImageInfo and Jython to get information from a image on
I'm trying to get my UITableView to show cells with images placed on them
I'm trying to read in 17 images from the Internet while displaying a splash
Im trying to write something to get my images to show correctly. I have
I'm trying to get the source attribute of all images withing a specific div
I have css hover over images for my tabs and I'm trying to get
I've been trying to get an Gtk2::Image object in this Perl Gtk2 application to
I've a crystal report that I'm trying to get a dynamic image displayed. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.