将变量加载到标签中


Load into label a variable

我在这个论坛上读到了一些关于这方面的内容,这是我的PHP代码:

<?
$percorso = file("emma.txt");
while(list(,$value) = each($percorso)){
list($aboutme, $aboutme2) = split("[:]", $value);
#declaration trim()
$params["aboutme"] = trim($aboutme);
$params["aboutme2"] = trim($aboutme2);
#print results
//put aboutme in label
//put aboutme2 in label2
}
?>

基本上:我有一个文本文件(emma.txt),里面有一些用新行分隔的信息。在这里你可以看到一个eaxpmle:

data_1

data_2

data_3…

有了这段代码,我阅读了每一行的内容,我想把内容放进一个标签中,但我不知道怎么做。这就是标签:<label name="lbl1">Nickname</label>

我想使用$_GET[]方法,因为我想用这些文本文件行设置标签的文本。我能做什么??

好的PHP:

您需要在while循环中输出标签,如下所示:

<?
$percorso = file("emma.txt");
while(list(,$value) = each($percorso)){
list($aboutme, $aboutme2) = split("[:]", $value);
#declaration trim()
$params["aboutme"] = trim($aboutme);
$params["aboutme2"] = trim($aboutme2);
#print results
//put aboutme in label
//put aboutme2 in label2
// Method 1: Output each line via PHP echo:
echo "<label name='lbl1'>".$params['aboutme']."</label>";
// etc...
// Method 2: Output via break PHP for HTML:
?>
<label name='lbl2'><?php echo $params['aboutme2']; ?></label>
etc...
<?php
// If using Method 2, don't forget to resume PHP here!
}
?>
相关文章: