dpzlz08480 2014-12-12 19:34
浏览 54
已采纳

如何制作一个脚本,在每行之后粘贴代码?

I'm creating a web, where I want one part of it to look something like this: Some text, followed by an audio tag with path to the audio file and then an underline(not an underline to text, but line that would separate the content) below that. This then repeats many times.

What I would like to do is to just write the line of text and then maybe write a tag or just leave the line of text. The script would just go thruough all the lines and paste there the audio tag with the filename (which would be just name_of_file*, where * would get by one bigger on each line) and the underline.

What I'm doing now is just pasting the audio tag and an hr tag after each line of text, then going through and manually writing the numbers of the files. And that is just stupid and tidious.

I'm familiar with HTML, CSS, and PHP. But I guess there is probably easier solution to this than to use PHP.

I hope you can understand what I mean and thanks for every answer!

  • 写回答

2条回答 默认 最新

  • duanqiu9104 2014-12-12 19:54
    关注

    You could get a text editor to do this, but if you already know PHP, I think it's much simpler to use that.

    $array=array(
        'line of text',
        'another line of text',
         array('text'=>'This one is special cause it has a tag', 'tag'=>'myTag'),
        'yet another line o text',
        .....
    );
    
    foreach($array as $index=>$val){
        if($index>0){
             echo '<hr>';
        }
    
        if(is_array($val)){
            echo $val['text'];
            echo 'tag: '.$val['tag'];
        }else{
            echo $val;
        }
    
        echo '<audio src="whatever_'.$index.'.oog">..put some <source> here...</audio>';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建