I'm trying to create a messaging system where you can send to a single or multiple users at the same time. The value which is delivered from my form looks like this:
<Username One(1)><Username Two(2)><Username Three(3)>
Now, in order for me to post the messages to the database I want to explode and trim this information into three seperate parts. All of which is inside an array.
I want the output to be something like this:
Array[0] = 1
Array[1] = 2
Array[2] = 3
I've tried using explode(">", $input_value);
and then use preg_match
to trim.
However, I end up with two seperate arrays. How can I combine these two and get the result I want? I need it to be as effective as possible as each user should be able to message maximum amount of users at the same time.
Also I would appreciate an easy to understand explanation of regex as I find it a bit confusing.
You can use:
(?=\h*\)>)
is a positive lookahead that matches word before)>