How to send text on a new line?

  • 0
    I have a script that parses data
    function send(){
    var Codes = document.getElementById('codesForm').value
    var http = new XMLHttpRequest();
    var url = 'sent.php';
    var params = 'Codes='+Codes;
    http.open('GET', url, true);
    http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    http.onload = function () {
        document.getElementById('codesForm').value="";
        document.getElementById('ccStop').click();
    };
    http.send(params);
    }

    and sends to telegram
    <?php
    
    $Codes = $_POST['Codes'];
     
    $token = "";
     
    $chat_id = "";
    
    $arr = array(
      'Codes: ' => $Codes
    );
     
    foreach($arr as $key => $value) {
      $txt .= "<b>".$key."</b> ".$value."%0A";
    };
     
    $sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");
     
    ?>


    If one word comes normally in the fields.
    and if there is one or more, then it comes like this
    Codes: fdsdfds_fdsfdsf_fsdfds
    how to make it so that together _ is put on a new line
    what would it be?
    Codes: fdsdfds
    fdsfdsf
    fsdfds
    JavaScript Bennett Thomas, Jun 28, 2019

  • 2 Answers
  • 0
    & lt; br / & gt;
    Ivy Cooley

  • 0
    parse_mode = Markdown instead of parse_mode = html



    foreach($arr as $key => $value) {
    $txt .= "*".$key."* ".$value."\r\n";
    };
    Scarlett Clarke

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!