johnsmith153 Posted April 23, 2011 Share Posted April 23, 2011 I have a text string and I need to find the value that appears after a certain value: Value that appears after "XXX:" "Test 123 Hello XXX: 1 Test 555"; So the value would be "1" Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/234542-searching-in-text/ Share on other sites More sharing options...
sunfighter Posted April 24, 2011 Share Posted April 24, 2011 I am assuming you know the number XXX. <?php $string = "Test 123 Hello XXX: 1 Test 555"; $sections = explode('XXX: ', $string); $number = explode(' ', $sections[1]); echo $number[0]; ?> Take notice of the spaces. Quote Link to comment https://forums.phpfreaks.com/topic/234542-searching-in-text/#findComment-1205558 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.