-
Notifications
You must be signed in to change notification settings - Fork 0
/
initial-message.php
39 lines (35 loc) · 1.05 KB
/
initial-message.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
<div class="twelve columns">
<?php
$punctuation = array('!', '?', '.');
require_once('digits-to-letters.php');
$filename = 'message.txt';
$file = fopen($filename, 'r');
$contents = fread($file, filesize($filename));
fclose($file);
//remove linebreak characters
$contents = preg_replace( array('/\r/', '/\n/'), '', $contents);
//reformat to normalize for punctuation
$contents = str_replace('!', ', !,', $contents);
$contents = str_replace('?', ', ?,', $contents);
$contents = str_replace('.', ', .,', $contents);
//create array with numbers in the message
$numbers = explode(', ', $contents);
?>
<?php
foreach ($numbers as $number){
?>
<div class="character<?php if( in_array( $number, $punctuation ) ){echo(' punctuation'); } ?>">
<div class="number">
<?php echo $number;?>
</div>
<div class="options">
<?php if( ! in_array( $number, $punctuation ) && isset($d2l[$number]) ){
echo $d2l[$number];
} ?>
</div>
<div class="letter"></div>
</div>
<?php
}
?>
</div>