Answer the question
In order to leave comments, you need to log in
Why does the bot give out an extra button on the dynamic keyboard?
The telegram bot has a dynamic keyboard, the number of buttons of which depends on the rows in the database, the text in these buttons is ordinary characters.
The problem is that if I try to add additional characters, the bot will give 1 more button, the text of which will be these added characters
Example:
Keyboard code without adding characters
$rows = $array_count;
$columns = 1;
$keyboard = [];
for ($i = 0; $i <= $rows; $i++) {
$rowKeys = [];
for ($j = 1; $j <= $columns; $j++) {
$token_get = secret_token_get($user_id)[$i];
$token_symbols = substr($token_get['token'], -5);
$rowKeys[] = ['text' => $token_symbols, 'callback_data' => 'token-' . $i]; // Нумерация токенов
}
$keyboard[] = $rowKeys;
}
$rows = $array_count;
$columns = 1;
$keyboard = [];
for ($i = 0; $i <= $rows; $i++) {
$rowKeys = [];
for ($j = 1; $j <= $columns; $j++) {
$token_get = secret_token_get($user_id)[$i];
$token_symbols = substr($token_get['token'], -5);
$rowKeys[] = ['text' => '***' . $token_symbols, 'callback_data' => 'token-' . $i]; // Нумерация токенов
}
$keyboard[] = $rowKeys;
}
Answer the question
In order to leave comments, you need to log in
You are iterating from zero up to and including the number of elements in the array. And it is necessary - not inclusive.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question