Last active
February 18, 2022 19:15
-
-
Save darkterminal/89c2ddf88431cfa5bd8ae641a761d788 to your computer and use it in GitHub Desktop.
Normalize Whitespace Characters using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//grepper php normalize whitespace characters | |
function normalizeWhitespaceCharacters( $string ) | |
{ | |
$stepOne = htmlentities($string); | |
$stepTwo = trim(preg_replace('/( )+|\s\K\s+/','', $stepOne)); | |
$final = html_entity_decode($stepTwo); | |
return $final; | |
} | |
//end grepper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment