April 30th, 2000, 10:57 PM
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?
April 30th, 2000, 11:44 PM
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
$sInput = "c:sanoimagesthisImage.gif";
$aPieces = explode ("", addslashes ($sInput));
echo ($aPieces[count ($aPieces) - 1]);
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";
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.