TEENFRONT Posted April 16, 2006 Share Posted April 16, 2006 hey , im working on a smiley site and i do this..upload smiley big-smile001.gifthen in the php file i set the row as the image name so $smileyname=$r["smileyname"];// $smileyname will = big-smile001.gif $getrid = array(".gif"); $cleaned = str_replace($getrid, "", "$smileyname");i get rid of the .gif bit so i can display just the name of the smiley without the .gif but it looks like the str_replace is getting rid of my 0'scoz it will output big-smile1 ( instead of big-smile001 ) , and this is a problem coz i link to the file using the outputted result... and big-smile1 isnt a file..big-smile001 is.so, any str_replace solutions for not getting rid of my 0's? Much appreciated if anyone knows the answer! TA! Quote Link to comment Share on other sites More sharing options...
TEENFRONT Posted April 16, 2006 Author Share Posted April 16, 2006 ahhhSorry guys, my fault i was replacing the wrong thing..nevermind.. this can be closed. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 16, 2006 Share Posted April 16, 2006 Don't make $getrid an array, just do:[code]<?php$getrid = '.gif';$cleaned = str_replace($getrid, '', $smileyname);?>[/code]Here's a more generic version, so you don't have to change you code if you decide to use both .gif * .jpg files:[code]<?php$x = pathinfo($smileyname);$cleaned = str_replace('.' . $x['extension'],'',$smileyname);?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.