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? Quote 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 Quote 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! Quote Link to comment https://forums.phpfreaks.com/topic/84181-string-manipulation-help/#findComment-428573 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.