phpretard Posted August 27, 2009 Share Posted August 27, 2009 How can I pull just the "123" out of $var. The numbers after the dash could be up to 10 digits In the end I need eliminate the dash and put everything after the dash into $var2 $var="41bab296a65b71736b464f8aff39b342-123" $var1="41bab296a65b71736b464f8aff39b342"; $dash="gone"; $var2="123"; Thank you. Link to comment https://forums.phpfreaks.com/topic/172154-solved-simple-parse-help/ Share on other sites More sharing options...
ignace Posted August 27, 2009 Share Posted August 27, 2009 $parts = explode('-', $var); print $parts[1]; Link to comment https://forums.phpfreaks.com/topic/172154-solved-simple-parse-help/#findComment-907710 Share on other sites More sharing options...
akitchin Posted August 27, 2009 Share Posted August 27, 2009 in order to remove the dash, you can use str_replace() to replace the dash with an empty string. as for ignace's code, in case there are multiple dashes and you only want the very last portion, use: $var2 = end($parts); rather than specifying $parts[1] explicitly. Link to comment https://forums.phpfreaks.com/topic/172154-solved-simple-parse-help/#findComment-907712 Share on other sites More sharing options...
phpretard Posted August 27, 2009 Author Share Posted August 27, 2009 Good Call Link to comment https://forums.phpfreaks.com/topic/172154-solved-simple-parse-help/#findComment-907713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.