PHP String method

Hey guys,

I want to split a string using a given character as a separator eg.

somedatasomemoredataevenmoredata

Is there a built in function to do this and how would I typically iterate through several tokens, saving each off into a variable then getting the next?

thanks

Silversurfer

If you’re using the same character as a separator (otherwise known as a delimiter), then you could probably use the explode() function:

PHP: explode - Manual

^^^ What he said… If you’re using several unique tokens in a single string, however, you may want to look into preg_split. (Though it doesn’t look like you’re doing that per your example)

Hi Silv m8

As above, explode does the job beautifully. If you want to do the reverse at any time then implode does the opposite.