How do I replace custom "tags" in a string?
- by Fake Code Monkey Rashid
Given the following:
$foo = "Yo [user Cobb] I heard you like dreams so I put a dream in yo dream in yo dream so you can dream while you dream while you dream."
I'd like to do this:
$foo = bar($foo);
echo $foo;
And get something like this:
Yo Cobb I heard you like dreams so I put a dream in yo dream in yo dream so you can dream while you dream while you dream.
I'm unsure of how the bar function should work. I think this is doable with regular expressions but I personally find those hard to understand. Using the strpos function is another method but I wonder if there is a better solution.
Pseudocode is fine but actual code will be appreciated.