Need Help greatly - text in tags
Posted: Mon Aug 11, 2008 9:32 am
(Please note in this post I have put * in some of the clsoing BBcode brackets so they output on the screen as code and do not get parsed.)
Hello all.
I have a feature that allows a user to enter BBCode, such as [img]IMAGE%20PATH[/img] etc...
What I need to ensure however is that there is no spaces within the [img] tags
So
[img]http://www.somesite.com/images/themoon.gif [*/img]
Would become
[img]http://www.somesite.com/images/themoon.gif[*/img]
But bare in mind the whole text would get passed to me as something like this:
All in one variable.
So I need to construct a function that will search that string for the image tags, and then get rid of any spaces inbetween, and return the whole string back to me in its new perfect form.
Any ideas? I ahve been trying to use preg_replace() etc.. but have not got anywhere - I can locate the text inbetween the [img] tags with this:
$Text = preg_replace("/\[img\](.+?)\[\/img\]/", '$1', $Text);
I think... but I am unsure on how I can then strip away the whitespace and then return it to the main string.
Any help much welcome!
Hello all.
I have a feature that allows a user to enter BBCode, such as [img]IMAGE%20PATH[/img] etc...
What I need to ensure however is that there is no spaces within the [img] tags
So
[img]http://www.somesite.com/images/themoon.gif [*/img]
Would become
[img]http://www.somesite.com/images/themoon.gif[*/img]
But bare in mind the whole text would get passed to me as something like this:
The Moon![*/b]
Some text here
a few line breaks etc..
[img]http://www.somesite.com/images/themoon.gif[*/img]
All in one variable.
So I need to construct a function that will search that string for the image tags, and then get rid of any spaces inbetween, and return the whole string back to me in its new perfect form.
Any ideas? I ahve been trying to use preg_replace() etc.. but have not got anywhere - I can locate the text inbetween the [img] tags with this:
$Text = preg_replace("/\[img\](.+?)\[\/img\]/", '$1', $Text);
I think... but I am unsure on how I can then strip away the whitespace and then return it to the main string.
Any help much welcome!