Gmunky Posted April 13, 2007 Share Posted April 13, 2007 If I have a string $string = "SELECT * FROM TABLE WHERE AGE > 0 ORDER BY NAME"; how would I retrieve part of the string before 'ORDER'; i want this part 'SELECT * FROM TABLE WHERE AGE > 0' if i use strstr($string,"ORDER"), this retrieves 'ORDER BY NAME' is there an opposite function of strstr()? Quote Link to comment https://forums.phpfreaks.com/topic/46891-help-with-string-manipulation/ Share on other sites More sharing options...
kenrbnsn Posted April 13, 2007 Share Posted April 13, 2007 You could use the explode() funciton: <?php $string = "SELECT * FROM TABLE WHERE AGE > 0 ORDER BY NAME"; list($part1,$part2) = explode(' ORDER',$string); echo $part1; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/46891-help-with-string-manipulation/#findComment-228600 Share on other sites More sharing options...
Gmunky Posted April 13, 2007 Author Share Posted April 13, 2007 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/46891-help-with-string-manipulation/#findComment-228601 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.