MyBB Community Forums

Full Version: [Solved] Need help with preg_replace
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So i am trying to display the last 5 topics from mybb to my own coded website.

I have the code and it works, but i want it to color the names depending on usergroup..

So i do some left joins and i get the contents of namestyle. Problem is, that i need to display the username instead of {username}.

Instead of

<span style="color: green;"><strong><em>{username}</em></strong></span>

It should be

<span style="color: green;"><strong><em>dikidera</em></strong></span>

But my website does not use templates so i have to use preg_replace. I tried

preg_replace("([{]username[}])", $namestyle, $replacement);

I found this on the internet and changed it, and it works, but kinda. It just replaces the whole html with my username in plain text(no html, no nothing)

Can anyone help?

EDIT: I am really sorry, it seems i was passing the wrong arguments to preg_replace. I fixed it and it works. Thank you. You may lock/delete the thread.