Please give me inspiration how to do this

i need to accomplish this

“blah blahblah blah blah [str_1|str-2|str_3] blah blah blah blahblah [str_4|str_5] blah blah [str_6|str_7|str_8|str_9] blah blah blah…”

process the sentence by taking randomly any ONE phrase wrapped inside , (where str_1 or str_2 …str_9 is consider as one phrase)

and thus turn into:–

“blah blahblah blah blah str-2 blah blah blah blahblah str_4 blah blah str_9 blah blah blah…”


“blah blahblah blah blah str_1 blah blah blah blahblah str_5 blah blah str_7 blah blah blah…”

clear example

“Hi Mike, [nice to see you|great to see you|surprise to see you] again! Are you still [doing|working on|researching] the [programing|coding] project? What is your [estimated|expected] time to [complete|finish] your [project|work]?”

process with some PHP codes:–

“Hi Mike, great to see you again! Are you still doing the programing project? What is your expected time to complete your work?”


“Hi Mike, nice to see you again! Are you still working on the coding project? What is your estimated time to finish your work?”


the first thing is to detect […] within the sentence, then we can use explode() with | as separator and randomly pick one phrase.

please give me a hint how to even begin??

Here, this thread will help.

exactly what i want here…

i am PHP self learner

Homework? :slight_smile:

but the tricky part for me is i wish to use ‘’ instead of ‘{}’


this looks like Martian language to me…

which char should i change? { ??