0

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!

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by kekkaishi
1

Escape forward slash.

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

Votes + Comments
Thnak you, that worked!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.