Forum Moderators: coopster

Message Too Old, No Replies

Help with code for stripping tags from data please.

         

Champak

1:16 am on Feb 3, 2006 (gmt 0)

10+ Year Member



Can someone tell me how to get the following to strip everything except a <br> tag:

function etz_striptags ($atts, $thing) {
return strip_tags(parse($thing));
}

...Also, how to add any extra tags to be excluded if needed later.

Thanks

coopster

1:35 am on Feb 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think you are working too hard ;)

strip_tags [php.net]

Champak

1:51 am on Feb 3, 2006 (gmt 0)

10+ Year Member



I already came across those, but they aren't working within the bigger script I have. This works, but it just strips everything. So I need to work within the confines of this, or come up with something totally new.

emodo

1:54 am on Feb 3, 2006 (gmt 0)

10+ Year Member



The title of this thread is misleading...

Woz

2:14 am on Feb 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hehe, that better?

;)

Onya
Woz

coopster

2:58 pm on Feb 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What? You've never seen a tag strip? ;)

I should have been a little more specific there Champak. There is an optional second argument to the strip_tags() function called

allowable tags.

string strip_tags [php.net] ( string str [, string allowable_tags] )

If you want to allow <br /> tags, you would specify that in this optional argument.

Champak

8:15 pm on Feb 3, 2006 (gmt 0)

10+ Year Member



OK, I put this in:

function etz_striptags ($atts, $thing[<br>]) {
return strip_tags(parse($thing));
}

and I get the following error on the page:

Parse error: syntax error, unexpected '[', expecting ')' in /home/XXXX/public_html/tester/lib/txplib_misc.php(459) : eval()'d code on line 1
The above errors were caused by the plugin:etz_striptags

Did I do something wrong, or will this just not work for me? Thanks.

coopster

8:56 pm on Feb 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You have your syntax a bit off here. It looks like you have a user-defined function named 'parse' that is doing a little something with the $thing variable before you strip the tags from it. The optional argument we are discussing here is an optional argument to the PHP strip_tags function, not your 'etz_striptags' user-defined function. So you have to get your optional argument in the right place:
function etz_striptags ($atts, $thing) { 
return strip_tags(parse($thing), '<br>');
}

a1call

9:09 pm on Feb 3, 2006 (gmt 0)

10+ Year Member



....that is doing a little something with the $thing

That made my day, thanks. [:-)]