Hello everyone.

I am working on this forum/post/script type thing.
What I want to do is convert this example to HTML.

[div]
[p]Some text[/]
[div]
Some more text
[/]
[/]

--->

<div>
<p>Some text</p>
<div>
Some more text
</div>
</div>

I don't want to use [/div] or [/p] to keep it short, but that is the problem where I get stuck.
This is what I've tried, it doesn't work:

$string = preg_replace('/\[div\](.*)\[/\]/s', '<div>\\1</div>', $string);

Please help!

Escape forward slash.

.. *)\[\/\]/s', '<div>\\1</div>', $string); Hope this would help you to carry on.

commented: Thnak you, that worked! +1
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.