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()? 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 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! Link to comment https://forums.phpfreaks.com/topic/46891-help-with-string-manipulation/#findComment-228601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.