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. 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. 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. 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
Archived
This topic is now archived and is closed to further replies.