wemustdesign Posted June 13, 2010 Share Posted June 13, 2010 I have names stored in a single column in my databse in the format: John Smith How would I format this to just output the first name as: John Quote Link to comment https://forums.phpfreaks.com/topic/204641-split-up-a-string/ Share on other sites More sharing options...
Daniel0 Posted June 13, 2010 Share Posted June 13, 2010 You can split a string by a delimiter using explode. Quote Link to comment https://forums.phpfreaks.com/topic/204641-split-up-a-string/#findComment-1071427 Share on other sites More sharing options...
wemustdesign Posted June 13, 2010 Author Share Posted June 13, 2010 Great, thanks Quote Link to comment https://forums.phpfreaks.com/topic/204641-split-up-a-string/#findComment-1071443 Share on other sites More sharing options...
dezkit Posted June 13, 2010 Share Posted June 13, 2010 <?php $str = "John Smith"; $str = explode( " " , $str ); echo $str[0]; // John echo $str[1]; // Smith ?> Quote Link to comment https://forums.phpfreaks.com/topic/204641-split-up-a-string/#findComment-1071478 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.