Answer the question
In order to leave comments, you need to log in
How to make buttons in a row for a telegram bot?
I'm trying to make 3 buttons in a row for a telegram bot
There is a script
$countrys = DB::$the->query("SELECT * FROM `set_country` WHERE `active` = '1' ");
while ($country = $countrys->fetch()) {
$keyboard[] = ];
}
$bot->sendInlineKeyboard($id, $text, $keyboard);
Now displays 1 in a row. To display 3 buttons, you need to do
$keyboard[] = ,['text' => $country['name'], 'callback_data' => ' orderNumber ' . $country['provider_type']],['text' => $country['name'], 'callback_data' => 'orderNumber ' . $country['provider_type']]];
But I can't figure out how to create such an array
Answer the question
In order to leave comments, you need to log in
keyboard accepts rows of lines with buttons. It turns out that the first array is the first row of buttons and so on. Moreover, if you specify 2 buttons in one of the rows of buttons, they will stretch along the width of the body of the messenger by 50% width. Or if you put 4 buttons in one row, they will be 25% each
$keyboard = [];
$1stButtonsLine = ['Раз', 'Два', 'Три'];
$2ndButtonsLine = ['Четыре', 'Пять', 'Шесть']
array_push($keyboard, $1stButtonsLine);
array_push($keyboard, $2ndButtonsLine);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question