tombe
Erfahrenes Mitglied
Also den Text "HundKatzeMaus" und "HausSonneBHWFeldweg" kann man damit trennen:
PHP:
<?php
function splitt($string){
$letter = "";
for ($a = 0; $a < strlen($string); $a++){
$letter .= substr($string, $a, 1);
if (ord(substr($string, ($a + 1), 1)) == ord(strtoupper(substr($string, ($a + 1), 1)))){
$word[] = $letter;
$letter = "";
}
}
for($a = 0; $a < count($word); $a++){
if (strlen($word[$a]) != 1){
$result[] = $word[$a];
} else {
$new = "";
while ($a < count($word) && strlen($word[$a]) == 1){
$new .= $word[$a];
$a++;
}
$a--;
$result[] = $new;
}
}
return implode(" ", $result);
}
$text = "HausSonneBHWFeldweg";
echo splitt($text);
echo "<br />";
$text = "HundKatzeMaus";
echo splitt($text);
?>