Page 1 of 1

Help with manipulating a string.

Posted: Sun Dec 14, 2003 4:37 pm
by michael_mead
Hi,

I have a string that looks like this;

example:example:example

It consists of three words, each seperated by colons and are of variable length.

I want to get these words from the string and put them into a variable.

Using php.net I can see a way to do it, but it looks very complicated and there must be an easier way that I have overlooked.

If someone could help me that would be great.

Thanks

Mike

Posted: Sun Dec 14, 2003 4:43 pm
by microthick
You can explode() them:

$mystring = "example:example:example";
$mywords = explode(":", $mystring);

Now an array called $mywords will exist that contains each of the words in $mystring.

Posted: Sun Dec 14, 2003 9:23 pm
by DuFF
More info and examples:

explode()

Posted: Mon Dec 15, 2003 7:12 am
by michael_mead
Hi,

Thats fantastic, when I am on my computer this evening, I will use that.

Thanks for your help, I dont know how I overlooked that.

Regards

Mike