I have spent about a couple of hours trying to read the pcre regex syntax on the php.net manual but I can't for the love of god grasp the concept of it. If anyone can help me it would be greatly appreciated.

I'm trying to split some strings into an array and I dont THINK that explode() would work since I wanna split this $str = '[str1][str2][str3]' into Array([0]=>'str1', [1]=>'str2', [2]=>'str3') I could use preg_split() or preg_match() and use the $match variable but I just don't know how to set the pattern that get the strings inside the [].

please help >_<

You could look for any number of characters ( [a-z0-9]* ) between '' in a preg_match_all. If the string within the brackets are always 'str' and then a number, you could also search for str[1-9] in a preg_match_all.

You could also use explode if you first replace one of the square brackets with nothing and then use the other bracket to explode the resulting string.

Hope you understood.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.