-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextPerevorot.php
More file actions
69 lines (66 loc) · 2.21 KB
/
Copy pathTextPerevorot.php
File metadata and controls
69 lines (66 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Text Perevorot</title>
<link rel="stylesheet" href="assets/reset.css">
<!-- <link rel="stylesheet" href="">-->
<link href="assets/css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<script src="assets/jquery-3.2.1.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<form action="TextPerevorot_handler.php" method="post">
<div class="form-group">
<label for="exampleInputEmail1">Some text</label>
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp"
placeholder="Enter some text" name="text">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
<label for="index1">index (№ буквы, которую нужно поменять местамис последней)</label>
<input type="text" name="index" id="index1">
</div>
<button type="submit" class="btn btn-primary">Перевернуть строку</button>
</form>
<?php
/**
* $start = 12;
* $end = 19;
* for ($i = $start; $i <= $end; $i++)
* {
* // echo $i.'<br>';
* for ($j = 0; $j < $i; $j++)
* {
* echo $i;
* }
* echo '<br>';
* }
*/
//
/**
* текст который подается на вход
* abcdefgggh
* порядковый номер (индекс) символа(буквы), которую будем менять местами с последней буквой, результат:
* abcdhgggfe
* @param $text
* @param $index
* @return string
*/
function revolutionString($text, $index)
{
echo $text.'<br>';
// $first = substr($text, 0, $index - 1);
// $temp = substr($text, $index - 1);
// $perevorot = strrev($temp);
// $result = $first.$perevorot;
// echo $result;
return substr($text, 0, $index - 1).strrev(substr($text, $index - 1));
}
/*$string = 'abcdefgggh';
$index = 5;
echo revolutionString($string, $index).'<br>';*/
?>
</body>
</html>