Skip to content
Advertisement

PHP: Telegram Bot: Insert line break to text message

"n" and "rn", tested in text message sent by telegram bot, to create line break. Instead of showing line break, underline _ will appear after using them.

How I could printing line feed in telegram message sent by bot?

CODE

$txt = 'با تشکر از عضویت شما، هر روز حدود ساعت 10 شب یک ویدئوی جالب برای شما ارسال خواهد شد.';
$txt .= " n ";
$txt .= 'Thanks for joining, Every day at almost 18:30 GMT an intersting video will be sent';

Message Demo enter image description here

Any help will be appreciated.

Advertisement

Answer

There is a better way! The problem is because of URL encodings… You can use normal PHP text using n but by passing it to urlencode method, as follows:

$txt = urlencode("here is my text.n and this is a new line n another new line");

It works for me!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement