-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathemoji.php
88 lines (76 loc) · 2.11 KB
/
emoji.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
<style>
.esize9 {
color: #000;
font-size: 80px;
}
.esize8 {
color: #111;
font-size: 70px;
}
.esize7 {
color: #222;
font-size: 60px;
}
.esize6 {
color: #333;
font-size: 50px;
}
.esize5 {
color: #444;
font-size: 40px;
}
.esize4 {
color: #555;
font-size: 35px;
}
.esize3 {
color: #666;
font-size: 30px;
}
.esize2 {
color: #777;
font-size: 25px;
}
.esize1 {
color: #888;
font-size: 20px;
}
</style>
<h2 style='margin:auto auto; text-align:center;'>Populārākie emotikoni</h2>
<?php
include 'includes/tag/classes/wordcloud.class.php';
$cloud = new wordCloud();
echo "<div style='text-align:center'>";
$query = "SELECT id, text FROM `tweets` WHERE `text` LIKE '%😊%'";
$unicodeRegexp = '([*#0-9](?>\\xEF\\xB8\\x8F)?\\xE2\\x83\\xA3|\\xC2[\\xA9\\xAE]|\\xE2..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?(?>\\xEF\\xB8\\x8F)?|\\xE3(?>\\x80[\\xB0\\xBD]|\\x8A[\\x97\\x99])(?>\\xEF\\xB8\\x8F)?|\\xF0\\x9F(?>[\\x80-\\x86].(?>\\xEF\\xB8\\x8F)?|\\x87.\\xF0\\x9F\\x87.|..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?|(((?<zwj>\\xE2\\x80\\x8D)\\xE2\\x9D\\xA4\\xEF\\xB8\\x8F\k<zwj>\\xF0\\x9F..(\k<zwj>\\xF0\\x9F\\x91.)?|(\\xE2\\x80\\x8D\\xF0\\x9F\\x91.){2,3}))?))';
$vardi = mysqli_query($connection, $query);
$emojiCounts = array();
while($r=mysqli_fetch_array($vardi)){
$text = $r["text"];
$id = $r["id"];
$emojis = has_emojis_old($text);
foreach ($emojis as $emoji){
if(!isset($emojiCounts[$emoji])){
$emojiCounts[$emoji] = 1;
}else{
$emojiCounts[$emoji] += 1;
}
}
}
arsort($emojiCounts);
foreach($emojiCounts as $moji => $count){
for($i=0;$i<$count;$i++){
$cloud->addWord(array('word' => $moji, 'url' => 'atslegvards/'.urlencode($moji)));
}
}
$cloud->setLimit(300);
$myCloud = $cloud->showCloud('array');
foreach ($myCloud as $cloudArray) {
echo ' <div style="display:inline-block;"><a href="'.$cloudArray['url'].'" class="word esize'.$cloudArray['range'].'">'.$cloudArray['word'].'</a></div> ';
}
echo "</div>";
function has_emojis_old($string) {
global $unicodeRegexp;
preg_match_all( $unicodeRegexp, $string, $matches_emo );
return $matches_emo[0];
}