duanlu1793 2019-04-17 00:19
浏览 89
已采纳

如何在echo中更改文本的位置?

I'm setting up a script for a friend, I want the landing_{random} to be added after the domain names but I whatever I do it shows behind the URL. How can I fix this issue?

I have tried moving the variables around and reversing places with the variables.

<?php
    $lines = file('domains.txt');
    foreach($lines as $line) {
        $randomString = substr(str_shuffle("0123456789abcdef"), 0, 1) . 
        substr(str_shuffle("0123456789abcdef"), 0, 6);
        $landing = "/landing_$randomString";
        /*echo "$line.'/landing_'.$randomString";*/
        echo "$line{$landing}";
    }
?>

I want when I input URL in http://example.com in domains.txt for it to output http://example.com/landing_d2ae5b3

  • 写回答

1条回答 默认 最新

  • douwei8911 2019-04-17 01:22
    关注

    It will not work like that Try instead:

    $landing = '/landing_".$randomString."';
    

    Should work fine now

    Update answer

    Try this

    $landing = "/landing_".$randomString."";
    

    By the way I think you may need to define array before use it like

    $lines = explode("" ,$lines);
    
    //then
    $landing = "/landing_".$randomString."";
    

    Also you may use this :

    echo "$line".$landing."";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题