JSHINER Posted October 2, 2007 Share Posted October 2, 2007 I currently use: substr($var], 3, 50) Which turns "123text" to "text" How can I get "123text123" to "text" Quote Link to comment https://forums.phpfreaks.com/topic/71590-solved-quick-substr-question/ Share on other sites More sharing options...
MmmVomit Posted October 2, 2007 Share Posted October 2, 2007 substr($var, 3, 4) http://www.php.net/manual/en/function.substr.php Quote Link to comment https://forums.phpfreaks.com/topic/71590-solved-quick-substr-question/#findComment-360418 Share on other sites More sharing options...
JSHINER Posted October 2, 2007 Author Share Posted October 2, 2007 But I need it scalable incase text is texttexttext (More than 4 characters) Quote Link to comment https://forums.phpfreaks.com/topic/71590-solved-quick-substr-question/#findComment-360421 Share on other sites More sharing options...
MmmVomit Posted October 2, 2007 Share Posted October 2, 2007 You're going to have to define the problem better. What exactly are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/71590-solved-quick-substr-question/#findComment-360422 Share on other sites More sharing options...
JSHINER Posted October 2, 2007 Author Share Posted October 2, 2007 The whole problem is I've had a very long day and solved the issue with substr($var, 3, -6) Every $var started with 123 and ended with 123456 so I just needed what was in the middle. Forgetting that using -6 would do the trick, I decided to post here. Coffee time Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/71590-solved-quick-substr-question/#findComment-360425 Share on other sites More sharing options...
trq Posted October 2, 2007 Share Posted October 2, 2007 That explains VERY little about your problem. Is your question actually how do I retrieve all the letters between a set of numbers? ? Quote Link to comment https://forums.phpfreaks.com/topic/71590-solved-quick-substr-question/#findComment-360427 Share on other sites More sharing options...
JSHINER Posted October 2, 2007 Author Share Posted October 2, 2007 Sorry, the problem was solved. In the example I simply used #'s to separate the pieces. I needed to get rid of the first 3 characters, and last 6. So let's say we had ABCDEFGHIJKLMNO - I only wanted DEFGHI. Quote Link to comment https://forums.phpfreaks.com/topic/71590-solved-quick-substr-question/#findComment-360428 Share on other sites More sharing options...
MmmVomit Posted October 2, 2007 Share Posted October 2, 2007 Actually, I didn't know that trick with the negative numbers. I would have suggested using strlen. Good to know. Quote Link to comment https://forums.phpfreaks.com/topic/71590-solved-quick-substr-question/#findComment-360434 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.