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 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. 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 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 ?> Link to comment https://forums.phpfreaks.com/topic/204641-split-up-a-string/#findComment-1071478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.