douliu7929 2013-07-02 23:17
浏览 33
已采纳

加载到变量标签中

I've read on this forum some stuff about this and this is my PHP code:

<?
$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
}
?>

Basically: I have a text file (emma.txt) that has some infos inside separated by a new line. Here you can see an eaxpmle:

data_1

data_2

data_3...

With that code I read the content of each single line and I'd like put the content into a label, but I don't know how to do it. This is the label: <label name="lbl1">Nickname</label>.

I was thinking to use the $_GET[] method, because I want set the labels' text with those text file lines. What can I do??

  • 写回答

1条回答 默认 最新

  • dtvfxzq3802 2013-07-02 23:20
    关注

    Good ol'fashion PHP:

    You would need to output the labels within the while loop like so:

    <?
    $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!
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作