<?php
function strim($str) {
$s1 = preg_replace('/[\pZ\pC]/muS',' ',$str);
if(preg_last_error()) {
$s1 = preg_replace('/[\pZ\pC]/muS',' ', iconv("UTF-8", "UTF-8//IGNORE", $str));
if(preg_last_error()) {
return trim(str_replace(array(' ',' ',' ',' ',' '), ' ', $str));
}
}
return trim(preg_replace('/ {2,}/muS', ' ', $s1));
}
echo "=".strim(" b áóñÑ baba bab")."=";
preferences:
30.05 ms | 402 KiB | 5 Q