![]() |
Here is Probably better here for a regex replace. |
Example:
PHP
// Strip HTML Tags
$clear = strip_tags($des);
// Clean up things like &
$clear = html_entity_decode($clear);
// Strip out any url-encoded stuff
$clear = urldecode($clear);
// Replace non-AlNum characters with space
$clear = preg_replace('/[^A-Za-z0-9]/', ' ', $clear);
// Replace Multiple spaces with single space
$clear = preg_replace('/ +/', ' ', $clear);
// Trim the string of leading/trailing space
$clear = trim($clear);
$clear = trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($des))))));
Example:
PHP
<?php
$clear = strip_tags($des);
?>
Example:
PHP
<?php
$clear = html_entity_decode($clear);
?>
Example:
PHP
<?php
$clear = urldecode($clear);
?>
Example:
PHP
<?php
$clear = preg_replace('/[^A-Za-z0-9]/', ' ', $clear);
?>
<?php
$clear = preg_replace('/ +/', ' ', $clear);
?>
<?php
$clear = trim($clear);
?>
Example:
PHP
<?php
$clear = trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($des))))));
?>
html string |
PHP Strip HTML Tags | PHP String Tutorial |
PHP Clean up things like & | PHP String Tutorial |
PHP Strip out any url-encoded stuff | PHP String Tutorial |
PHP Replace non-AlNum characters with space | PHP String Tutorial |
PHP Replace Multiple spaces with single space | PHP String Tutorial |
PHP Trim the string of leading/trailing space | PHP String Tutorial |
PHP Special Tag Replace | PHP String Tutorial |
Type
: |
Develop |
Category
: |
Web Tutorial |
Sub Category
: |
PHP String Tutorial |
Uploaded by
: |
Admin |