我正在使用html和PHP从文件中读取文本并在页面中回显 - 这是一种列表。 问题是我不想把它放在页面的顶部,因为默认情况下是PHP回显,而是把它放在特定的地方 - 在div之后和之前。
php片段:
@Override
public void onConfigurationChanged(Configuration newConfig) {
int currentKeyboard = 0;
boolean isShifted = kv.isShifted();
for (int i = 0; i < keyboard.length; i++) {
if(kv.getKeyboard().equals(keyboard[i])){
currentKeyboard = i;
break;
}
}
super.onConfigurationChanged(newConfig);
initializeKeyboardArray();
setKeyboard(keyboard[currentKeyboard]);
kv.setShifted(isShifted);
}
private void initializeKeyboardArray(){
keyboard = new Keyboard[7];
keyboard[ARABIC] = arabic;
keyboard[ARABIC_SHIFT] = arabicShift;
keyboard[ARABIC_SYMBOLS] = arabicSymbols;
keyboard[ARABIC_SYMBOLS_SHIFT] = arabicSymbolsShift;
keyboard[QWERTY] = qwerty;
keyboard[QWERTY_SYMBOLS] = qwertySymbols;
keyboard[QWERTY_SYMBOLS_SHIFT] = qwertySymbolsShift;
}
感谢。
答案 0 :(得分:1)
您可以为希望将其置于HTML中的div保存FOREACH循环
<?php
$lines = file('http://localhost/repositories.txt');
?>
<html>
<div>Some other text on my page</div>
<div><?php foreach ($lines as $line_num => $line) {
echo "<a onclick='javascript:(document.folderForm.folderLocation.value=".htmlspecialchars(json_encode($line)) .");' href='#'>".htmlspecialchars($line) . "</a><br />"; ?></div>
</html>
答案 1 :(得分:0)
例如:
<?php
$lines = file('http://localhost/repositories.txt');
$list=""; //declare empty varialbe
foreach ($lines as $line_num => $line) {
$list .= "<a onclick='javascript:(document.folderForm.folderLocation.value=".htmlspecialchars(json_encode($line)) .");' href='#'>".htmlspecialchars($line) . "</a><br />";
/* .= cause the append to the variable */
}
?>
<html>
<head>
<meta ....... />
</head>
<body>
<div>Some div</div>
<div><?php echo $list; ?></div>
<div>Some div</div>
</body>
</html>
答案 2 :(得分:-1)
把你所有的html垃圾放在这里然后当你准备好添加这个<?
$ lines = file(&#39; http://localhost/repositories.txt&#39;);
foreach($ line as $ line_num =&gt; $ line)echo&#34;&#34; .htmlspecialchars($ line)。 &#34;
&#34 ;; ?>
打开和关闭的php标记可以让你把它准确地放在你想要的地方