aximbigfan Posted September 30, 2008 Share Posted September 30, 2008 Hi, Let's say I have this variable $vari = '/1/2/3/'; Now, I have this string: $otherstr = '/1/2/3/4/break/1/2/3/'; Basically what I need to do is get rid of $vari in the BEGINNING on $otherstr. Is there anyway to do this? Thanks, Chris Quote Link to comment Share on other sites More sharing options...
hamza Posted September 30, 2008 Share Posted September 30, 2008 $otherstr is static or dynamic. mean every time it created with the same name if you answer is yes then you should use the code is below <?php $str ="$otherstr = '/1/2/3/4/break/1/2/3/'"; echo str_replace("$otherstr =","",$str); ?> this code will show you the /1/2/3/4/break/1/2/3/ only Quote Link to comment Share on other sites More sharing options...
discomatt Posted September 30, 2008 Share Posted September 30, 2008 <pre><?php $vari = '/1/2/3/'; $otherstr = '/1/2/3/4/break/1/2/3/'; if( strpos($otherstr, $vari) === 0 ) $otherstr = substr( $otherstr, strlen($vari) ); echo $otherstr; ?></pre> Quote Link to comment Share on other sites More sharing options...
aximbigfan Posted September 30, 2008 Author Share Posted September 30, 2008 Hi Guys, Got it working, thanks! Chris 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.