rsammy Posted October 31, 2007 Share Posted October 31, 2007 i have a sting which is 18 characters in length. the first character starts off with either a 'P' or a 'Q' followed by 17 numerics. (something like this:P12220070806181242 or Q12220071030162349). i do not have enough room on the screen to display this entire string as it is. I want to crop it. would like to display the first character('P' or 'Q') followed by the last 8 digits(06181242 or 30162349). how can i do this? the string should show up as Q30162349 or P06181242 to be able to save space on the display screen. any help will be greatly appreciated. thanx Link to comment https://forums.phpfreaks.com/topic/75506-solved-help-with-string-manipulation/ Share on other sites More sharing options...
Orio Posted October 31, 2007 Share Posted October 31, 2007 <?php $str = "Q123456789987654321"; echo substr($str,0,1).substr($str,strlen($str)-; ?> Or if the string is always 18 chars long simply replace the strlen($str)-8 with 10. Orio. Link to comment https://forums.phpfreaks.com/topic/75506-solved-help-with-string-manipulation/#findComment-381934 Share on other sites More sharing options...
rsammy Posted October 31, 2007 Author Share Posted October 31, 2007 thank u sir! appreciate ur help Link to comment https://forums.phpfreaks.com/topic/75506-solved-help-with-string-manipulation/#findComment-381973 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.