bmdsherman Posted September 13, 2009 Share Posted September 13, 2009 I have a variable, $photo, that is equal to 1.jpg, I want to remove the ".jpg" part from the variable so the variable is only "1", does anybody know how I can do that? Quote Link to comment https://forums.phpfreaks.com/topic/174133-solved-remove-part-or-varible/ Share on other sites More sharing options...
.josh Posted September 14, 2009 Share Posted September 14, 2009 $photo = substr($photo,0,-4); echo $photo; or $photo = explode('.',$photo); echo $photo[0]; or preg_match('~^[^.]+~',$photo,$match); echo $match[0]; Quote Link to comment https://forums.phpfreaks.com/topic/174133-solved-remove-part-or-varible/#findComment-917915 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.