Omzy Posted January 13, 2010 Share Posted January 13, 2010 I have a string variable, which for example can have the following values: $string="This is a normal description" $string="This is another description [advanced]" Basically I want to echo $string but if it finds a "[" (square bracket) character in the string it will not echo that part. The square braket, if there is one, will only appear at the end of the string. Quote Link to comment Share on other sites More sharing options...
salathe Posted January 13, 2010 Share Posted January 13, 2010 Very similar questions seem to pop up here very regularly. If you're using PHP 5.3 then you can use strstr with its handy 3rd parameter, or you could use any number of other string-functions such as strtok. Quote Link to comment Share on other sites More sharing options...
Omzy Posted January 13, 2010 Author Share Posted January 13, 2010 Hi salathe. I was initially going to use strstr() but then I realised it only works with PHP 5.3. I've just tried strtok() and that seems to do the job. Thanks. 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.