PDA

View Full Version : php image gallery script...


ikris
08-29-2002, 12:48 AM
Here (http://version.not-impossible.org/photos/sgs.php?gal=gallery/sub1/) is the page in question. Thre is nothing wrong with the script itself but I'm having a cosmetic problem with it. The caption for each photo is taken from the file name of the pic. I need to know what the coding would be to strip the file name of the underscore in the file name and replace it with a space.. Thanks

Spookster
08-29-2002, 01:02 AM
http://www.php.net/manual/en/function.str-replace.php

ikris
08-29-2002, 01:05 AM
I'll check that out and see what it does for me... Thanks

ikris
08-29-2002, 01:10 AM
Ok, I read through it and I'm very confused. How would I implement this into a script so that when it writes the file name as the caption, it takes out the underscore and adds a space if the file name was something like "hey_there.jpg"?

firepages
08-29-2002, 02:56 AM
<?
echo str_replace('_',' ',$filename);
?>

Ökii
08-29-2002, 11:20 AM
Or, for a bit more text formatting - eg Capital first letter and lose the .jpg or .png bit

$filename = 'here_is_my_file.jpg';
echo ucfirst(str_replace('_',' ',substr($filename,0,-4)));