sungpeng Posted July 1, 2009 Share Posted July 1, 2009 $variable="bedroom.jpg"; Can check with all of you how to ignore the ".jpg" and get the character "bedroom" only? Quote Link to comment Share on other sites More sharing options...
abdfahim Posted July 1, 2009 Share Posted July 1, 2009 $variable="bedroom.jpg"; $vararr=explode(".",$variable); $variable=$vararr[0]; Quote Link to comment Share on other sites More sharing options...
sungpeng Posted July 1, 2009 Author Share Posted July 1, 2009 Thank abdbuet Quote Link to comment Share on other sites More sharing options...
joel24 Posted July 1, 2009 Share Posted July 1, 2009 but if it were a file like 'bedroom.old.jpg', explode wouldn't work? well it would, but you'd only get 'bedroom' and not 'bedroom.old' you can use the pathinfo() function http://us3.php.net/manual/en/function.pathinfo.php $file = 'bedroom.jpg'; $filename = pathinfo($bedroom, PATHINFO_FILENAME); Quote Link to comment Share on other sites More sharing options...
abdfahim Posted July 1, 2009 Share Posted July 1, 2009 yup .. ryt .. or may be $variable = substr($variable, 0, -4); there are lots of alternate way as well 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.