Last active
May 22, 2024 14:41
-
-
Save JamshidbekAkhlidinov/cd5f4fac94ec1e58fed82df4e12ca411 to your computer and use it in GitHub Desktop.
Used to make several spaces into one.
This file contains hidden or 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 | |
function clearBetweenOnText($text) | |
{ | |
$array = explode(" ", $text); | |
$ClearArray = array_filter($array, function ($value) { | |
return !empty(trim($value)); | |
}); | |
$arrayValues = array_values($ClearArray); | |
return implode(" ", $arrayValues); | |
} | |
$string = 'Some valid and dsad text!'; | |
echo clearBetweenOnText($string). "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment