![]() |
Here is Probably better here for a regex replace. |
// 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))))));
<?php
$clear = strip_tags($des);
?>
<?php
$clear = html_entity_decode($clear);
?>
<?php
$clear = urldecode($clear);
?>
<?php
$clear = preg_replace('/[^A-Za-z0-9]/', ' ', $clear);
?>
<?php
$clear = preg_replace('/ +/', ' ', $clear);
?>
<?php
$clear = trim($clear);
?>
<?php
$clear = trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($des))))));
?>
html string |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | PHP String Tutorial |
Uploaded by: | Admin |