<?php
function vk($text) {
if (strlen($text) <= 10000) {
$start=$text;
$result="";
$error="Максимальное количество символов - 10000";
for($i = 0; $i < strlen($text); $i++)
{
if (!($i%2)) {
$result=$result.strtoupper($start[$i]);
} else {
$result=$result.strtolower($start[$i]);
}
}
return htmlspecialchars($result);
} else {
return $error;
}
}
if(!isset($_POST['tc'])) {
?>
<form action="" method="POST">
<input type="textarea" rows="10" cols="50" name="txt"><br>
<input type="submit" value="ТЫЦ" name="tc">
</form>
<?php } else { ?>
<form action="" method="POST">
<input type="textarea" rows="10" cols="50" name="txt"><br>
<input type="submit" value="ТЫЦ" name="tc">
<?php echo vk($_POST['txt']); ?>
</form>
<?php } ?>
Тоже самое, но короче:
<html>
<form action="form.php" method="GET">
<input name="form">
<button submit="form">GO</button>
</html>
<?php
echo "<br>"."<br>"."<center>";
$one = $_GET["form"];
for ($i=0;$i<strlen($one);$i+=2)
{
$one[$i]=strtoupper($one[$i]);
}
echo $one;
?>