mcmuney Posted January 19, 2013 Share Posted January 19, 2013 I'm trying to pull a certain number of characters after a specific character. For example: $data="x=1234567" I'd like to pull 7 characters after "x=". So the result whould be "1234567". I couldn't use strpos because the 7 characters will NOT always begin from the 3rd character. For example, it could be "x=" or "tyx=" or "1x=", etc. I only want what's after "x=". Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/273365-help-with-character-extraction/ Share on other sites More sharing options...
Jessica Posted January 19, 2013 Share Posted January 19, 2013 Use explode and substr. Quote Link to comment https://forums.phpfreaks.com/topic/273365-help-with-character-extraction/#findComment-1406970 Share on other sites More sharing options...
Christian F. Posted January 20, 2013 Share Posted January 20, 2013 What's wrong with just substr (), I mean if you know you always want 7 characters? php > $data="x=1234567"; php > echo substr ($data, -7); 1234567 Otherwise, you can use strpos () to find the position of the equals sign, and send that value to substr (). Quote Link to comment https://forums.phpfreaks.com/topic/273365-help-with-character-extraction/#findComment-1407123 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.