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 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计