-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·137 lines (122 loc) · 3.66 KB
/
index.php
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
include( 'src/OrdinalNumber.php' );
use MartinJoiner\OrdinalNumber\OrdinalNumber as OrdinalNumber;
$pageTitle = 'Demonstration of OrdinalNumber PHP Class';
?><!DOCTYPE html>
<html>
<head>
<title><?=$pageTitle?></title>
<style type="text/css">
body{
font-family: arial, sans-serif;
}
table{
border-collapse: collapse;
}
td, th{
padding: 0 1.3em;
line-height: 2em;
border: 1px solid #CCC;
}
.code{
font-family: monospace;
background-color: #333;
color: #EEE;
}
</style>
</head>
<body>
<h1><?=$pageTitle?></h1>
<h2>By Martin Joiner</h2>
<code>
<p>function convert( $num, $appendAnd = false, $titleCase = false )</p>
</code>
<table>
<thead>
<tr>
<th>Scenario</th>
<th>PHP code</th>
<th>Resulting string</th>
</tr>
</thead>
<tbody>
<tr>
<td>Convert the number 1</td>
<td class="code">print OrdinalNumber::convert(1);</td>
<td><?=OrdinalNumber::convert(1)?></td>
</tr>
<tr>
<td>Just convert 378</td>
<td class="code">print OrdinalNumber::convert(378);</td>
<td><?=OrdinalNumber::convert(378)?></td>
</tr>
<tr>
<td>Just convert 40</td>
<td class="code">print OrdinalNumber::convert(40);</td>
<td><?=OrdinalNumber::convert(40)?></td>
</tr>
<tr>
<td>Just convert 400</td>
<td class="code">print OrdinalNumber::convert(400);</td>
<td><?=OrdinalNumber::convert(400)?></td>
</tr>
<tr>
<td>Just convert 4000</td>
<td class="code">print OrdinalNumber::convert(4000);</td>
<td><?=OrdinalNumber::convert(4000)?></td>
</tr>
<tr>
<td>Just convert 4000 with the "and" added (no effect)</td>
<td class="code">print OrdinalNumber::convert(4000,true);</td>
<td><?=OrdinalNumber::convert(4000,true)?></td>
</tr>
<tr>
<td>Convert 872 in title case</td>
<td class="code">print OrdinalNumber::convert(872,false,true);</td>
<td><?=OrdinalNumber::convert(872,false,true)?></td>
</tr>
<tr>
<td>Convert 9278</td>
<td class="code">print OrdinalNumber::convert(9278);</td>
<td><?=OrdinalNumber::convert(9278)?></td>
</tr>
<tr>
<td>Convert 9278 with the "and" added</td>
<td class="code">print OrdinalNumber::convert(9278,true);</td>
<td><?=OrdinalNumber::convert(9278,true)?></td>
</tr>
<tr>
<td>Convert 101</td>
<td class="code">print OrdinalNumber::convert(101);</td>
<td><?=OrdinalNumber::convert(101)?></td>
</tr>
<tr>
<td>Convert 101 with the "and" added</td>
<td class="code">print OrdinalNumber::convert(101,true);</td>
<td><?=OrdinalNumber::convert(101,true)?></td>
</tr>
<tr>
<td>Convert 10 with the "and" added</td>
<td class="code">print OrdinalNumber::convert(10,true);</td>
<td><?=OrdinalNumber::convert(10,true)?></td>
</tr>
<tr>
<td>Convert 9999 with the "and" added and in title case</td>
<td class="code">print OrdinalNumber::convert(9999,true,true);</td>
<td><?=OrdinalNumber::convert(9999,true,true)?></td>
</tr>
</tbody>
</table>
<h2>Sources</h2>
<p><a href="https://github.com/martinjoiner/ordinal-number">https://github.com/martinjoiner/ordinal-number</a></p>
<p><a href="https://packagist.org/packages/martinjoiner/ordinal-number">https://packagist.org/packages/martinjoiner/ordinal-number</a></p>
<h2>List of examples in increments of 7</h2>
<ul>
<?php
for ( $i = 1; $i < 9999; $i = $i + 7 ){
print "<li>" . number_format( $i ) . " = " . OrdinalNumber::convert($i, true, true) . "</li>";
}
?>
</ul>
</body>
</html>