#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Redmond, WA
    Posts
    218
    Rep Power
    15
    I have: c:sanoimagesthisImage.gif which is sent through an input box to a PHP variable. I'd like to strip that down to only thisImage.gif.

    Any suggestions on how to do this, and where I should start?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Posts
    38
    Rep Power
    15
    sounds like what you would need would be a regular expression what would just find the *.* part of it and then filter everything else out...
    dunno though, nothing easy
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 1999
    Posts
    114
    Rep Power
    16
    $sInput = "c:sanoimagesthisImage.gif";
    $aPieces = explode ("", addslashes ($sInput));
    echo ($aPieces[count ($aPieces) - 1]);

    -- Christopher
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Redmond, WA
    Posts
    218
    Rep Power
    15
    I figured it out on my own, did it a bit different than you, Christopher. By the way, great book!

    $image_info = split("", $image);
    $image_count = count($image_info);
    $image_file = "nimages/front/" . $image_info[($image_count - 1)] . "n";
  8. #5
  9. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    If you would like to know how this can be done in Perl, here it is. Basically the 'pop' function is being used.

    $full_path = "c:sanoimagesthisImage.gif";
    @each_path = split(//, $full_path);
    $file_name = pop @each_path;
    # $file_name will return the last value of @each_path array.

Similar Threads

  1. searching a string for a variable value
    By oakisland in forum Perl Programming
    Replies: 5
    Last Post: February 15th, 2004, 04:57 PM
  2. array explode ( string separator, string string [, int limit])
    By beemee_freeserv in forum HTML Programming
    Replies: 4
    Last Post: February 5th, 2004, 11:56 AM
  3. mgetty+sendfax on RH9
    By ayrin in forum Linux Help
    Replies: 0
    Last Post: January 31st, 2004, 03:11 AM
  4. [c++] Searching a characther in string
    By Crea23 in forum C Programming
    Replies: 3
    Last Post: January 12th, 2004, 11:05 PM
  5. Advice on reversing order of characters within a string?
    By FriscoKid in forum C Programming
    Replies: 5
    Last Post: November 13th, 2003, 09:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo