Jump to content

Recommended Posts

Hi I new to php and this forum ,

I need some help getting rid of some extra stuff in a string

 

the string will contain info like

 

"i my name is joe (dfdsfds jdsjkfjdsk)"

 

I want to cut out any thing in "(dfdsfds jdsjkfjdsk)"

 

so the string would look like

 

"i my name is joe"

 

so any thing between this "(random info)"

 

is they any way I can just cut off the end of the string starting with this"("  ?

thank you for any help

 

I tried those before the problem I have is the stuff I have in string changes so I was trying to find a way to chop the string off when it finds the first "("

you can use regex, or a combination of str_replace, strstr() and strrstr(). try reading the manual on regex, or those functions

you can use strpos to find the first occurance of "(" it will return the character position in the string.  You can then use substr to extract the part you want, starting at 0, and using the # returned from strpos for the length.

thank you that worked great!!! :)

you can use strpos to find the first occurance of "(" it will return the character position in the string.  You can then use substr to extract the part you want, starting at 0, and using the # returned from strpos for the length.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.