E
E
Evgeny2021-07-13 01:47:21
PHP
Evgeny, 2021-07-13 01:47:21

How to separate buttons in a telegram bot message?

I can’t figure out how to split the buttons under the message into rows and columns, the bot simply displays a message with buttons in a row (and then more than 8 buttons in a row all fit)
60ecc64783b47578509315.png
Buttons 4 and 5 need to be in the 2nd row

$inline_keyboard_questions_account = [],
            'reply_markup' => inline_keyboard($inline_keyboard_questions_account)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anastasia, 2021-07-13
@fakin_kiska

$mata["reply_markup"] = json_encode([
      "keyboard" => [
        ,
        , // вторая строка
        ,
      ]
    ]);

It's about arrays. I have an array where each array is a string. In this array, every other array is a button
. In your case:
$inline_keyboard_questions_account = [
    [
        ['text' => '№1', 'callback_data' => 'question 1'],
        ['text' => '№2', 'callback_data' => 'question 2'],
        ['text' => '№3', 'callback_data' => 'question 3']
    ],
    [
        ['text' => '№4', 'callback_data' => 'question 4'],
        ['text' => '№5', 'callback_data' => 'question 5']
    ]
];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question