PHP: Telegram Bot: Insert line break to text message
To insert a line break in a text message sent from a Telegram bot written in PHP, use the special characters "\n" in the message string. For example:
<?php
$message = "Line 1\nLine 2";
sendMessage($chat_id, $message);
This will create a new line after "Line 1".
If you're using Telegram bot API library, you can use PHP_EOL
instead of \n
, it will work the same way.
<?php
$message = "Line 1" . PHP_EOL . "Line 2";
sendMessage($chat_id, $message);