Tech Tip: Stripping HTML tags from Text in 4D using PHP
PRODUCT: 4D | VERSION: 13.5 | PLATFORM: Mac & Win
Published On: September 25, 2014
If you have a text string that contains HTML elements and wouldl ike to strip out all of the HTML tags leaving only the plain text, take a look at the PHP command strip_tags
This PHP command strip_tags can be used from 4D like this:
C_TEXT($input;$output) C_BOOLEAN($isOk) $isOk:=PHP Execute("";"strip_tags";$output;$input) |
So if you have a string like this:
$input:="<br>this <b>is <ul><li>bold</li></ul></b><br />" |
You can convert it to plain text like this:
C_TEXT($input;$output) C_BOOLEAN($isOk) $input:="<br>this <b>is <ul><li>bold</li></ul></b><br />" $isOk:=PHP Execute("";"strip_tags";$output;$input) ALERT($output) |
Which returns:
this is bold |