-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_new.php
52 lines (37 loc) · 960 Bytes
/
show_new.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
<?php
//mb_internal_encoding('UTF-8');
include('kanji.php');
$query = "SELECT * FROM kanji ORDER BY RAND() LIMIT 1";
$kanji = new Kanji();
$kanji->query($query);
$k = $kanji->kanji;
$e = $kanji->english_translation;
$p = $kanji->pronunciation;
$l = $kanji->link;
if (!$l) {
$l = 'http://jisho.org/kanji/details/'.$k;
}
$response = array(
'kanji' => $k,
'english_translation' => $e,
'pronunciation' => $p,
'link' => $l,
);
echo json_encode($response);
/*$dom = new DOMDocument('1.0', 'utf-8');
$k = $dom->createElement('kanji', $kanji->kanji);
$e = $dom->createElement(
'english_translation',
$kanji->english_translation
);*/
/*$p = $dom->createElement('pronunciation', $kanji->pronunciation);
$dom->appendChild($k);
$dom->appendChild($e);
$dom->appendChild($p);
echo $dom->saveXML();*/
/*
<span id="kanji"><?php echo $k; ?></span>
<span id="english"><?php echo $e; ?></span>
<span id="pronunciation"><?php echo $p; ?></span>
*/
?>