project3 Posted February 8, 2008 Share Posted February 8, 2008 I have a string and want to repace the first 14 digits with x's how would I go about doing that? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 I would use a combination of the substr() and str_replace() functions: <?php $str = "this is a very long string that is longer that 14 characters long"; $x = 'xxxxxxxxxxxxxx'; $new_str = str_replace(substr($str,0,14),$x,$str); echo $str . '<br>' . $new_str; ?> Ken Quote Link to comment 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.