extrovertive Posted January 2, 2008 Share Posted January 2, 2008 body-pop big-c t-cat-man becomes bodyPop bigC tCatMan What's the simplest way to do this, given a string? Link to comment https://forums.phpfreaks.com/topic/84181-string-manipulation-help/ Share on other sites More sharing options...
kenrbnsn Posted January 2, 2008 Share Posted January 2, 2008 User the explode(), ucword(), and implode() functions: <?php $strs = array('body-pop','big-c','t-cat-man'); foreach ($strs as $str) { $tmp = explode('-',$str); for ($i=1;$i<count($tmp);$i++) $tmp[$i] = ucwords($tmp[$i]); echo 'Original: ' . $str . ' ---> ' . implode('',$tmp) . '<br>'; } ?> Ken Link to comment https://forums.phpfreaks.com/topic/84181-string-manipulation-help/#findComment-428566 Share on other sites More sharing options...
extrovertive Posted January 2, 2008 Author Share Posted January 2, 2008 Thanks - took me hours to come up w/ something! Link to comment https://forums.phpfreaks.com/topic/84181-string-manipulation-help/#findComment-428573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.