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! Link to comment https://forums.phpfreaks.com/topic/7551-help-with-str_replace/ 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. Link to comment https://forums.phpfreaks.com/topic/7551-help-with-str_replace/#findComment-27513 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 Link to comment https://forums.phpfreaks.com/topic/7551-help-with-str_replace/#findComment-27515 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.