oni-kun Posted December 7, 2009 Share Posted December 7, 2009 I have a hash that is 32 characters long, it's concatenated after another string which is of variable length. How do I extract anything before the end 32 characters? "$string . md5(...);" is what I have to give a clearer picture. I've tried everything with string manipulation and couldn't find a fully working method.. I can't find what just $string is. Quote Link to comment https://forums.phpfreaks.com/topic/184221-use-string-before-end-32-characters/ Share on other sites More sharing options...
Brandon_R Posted December 7, 2009 Share Posted December 7, 2009 Considering the last 32 characters of the string is the hash and you want to remove it use this: $string = substr($string, 0, -32); If you want to remove everything except the hash use this $string = substr($string, -32); Again both is dependent on the 32 digit long hash being on the end of the string as you stated. Quote Link to comment https://forums.phpfreaks.com/topic/184221-use-string-before-end-32-characters/#findComment-972605 Share on other sites More sharing options...
oni-kun Posted December 7, 2009 Author Share Posted December 7, 2009 Works perfectly, and I learned a thing about strings! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/184221-use-string-before-end-32-characters/#findComment-972614 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.