ACC SHELL
<?php
function slabiky( $text ) {
$arr = array();
if ( strlen( $text) <= 3 ) {
$arr[] = $text;
} else {
$chars = array( 'a', 'e', 'i', 'o', 'u' );
$pos = 0;
while ( $pos < strlen( $text ) ) {
if ( strlen( $text ) - $pos <= 3 ) {
$arr[] = substr( $text, $pos, strlen( $text ) - $pos );
$pos = strlen( $text );
} elseif ( strpos( $text, 'r', $pos )+1-$pos == 3 && $pos + 3 < strlen( $text ) - 1 ) {
$arr[] = substr( $text, $pos, strpos( $text, 'r' )+1-$pos );
$pos += strpos( $text, 'r', $pos )+1-$pos;
} else {
$find = FALSE;
for ( $i = 0; $i < count( $chars ); $i++ ) {
if ( strpos( $text, $chars[ $i ], $pos )+1-$pos == 2 || strpos( $text, $chars[ $i ], $pos )+1-$pos == 3 ) {
$arr[] = substr( $text, $pos, strpos( $text, $chars[ $i ], $pos )+1-$pos );
$pos += strpos( $text, $chars[ $i ], $pos )+1-$pos;
$find = TRUE;
break;
}
}
if ( !$find ) {
$arr[] = substr( $text, $pos, 3 );
$pos += 3;
}
}
}
}
return $arr;
}
$sl = slabiky( 'tabulatura' );
for ( $i = 0; $i < count($sl); $i++ ) {
if ( $i == count( $sl )-1 ) {
echo "<strong>". $sl[ $i ]. "</strong>";
} else {
echo $sl[ $i ]. " - ";
}
}
$sl = slabiky( 'priklady' );
for ( $i = 0; $i < count($sl); $i++ ) {
if ( $i == count( $sl )-1 ) {
echo "<strong>". $sl[ $i ]. "</strong>";
} else {
echo $sl[ $i ]. " - ";
}
}
$sl = slabiky( 'ostrov' );
for ( $i = 0; $i < count($sl); $i++ ) {
if ( $i == count( $sl )-1 ) {
echo "<strong>". $sl[ $i ]. "</strong>";
} else {
echo $sl[ $i ]. " - ";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<body>
<form method="POST">
<input type="text" name="text" />
<input type="submit" value="Odeslat" />
</form>
</body>
</html>
ACC SHELL 2018