Closed
Description
I know about InlineKeyboard
class, can get each inline keyboard buttons as separated argument.
new InlineKeyboard($keyboard_buttons1, $keyboard_buttons2, ...);
Now I have $menus
dynamical array of callback's data.
I want to read all the data with foreach
and make category 3 each for every line I create.
Sample code:
$menus = [
'x1'=>'y1',
'x2'=>'y2',
'x3'=>'y3',
'x4'=>'y4',
'x5'=>'y5',
'x6'=>'y6',
'x7'=>'y7',
];
$keyboard_buttons = [];
$keyboard_buttons_line = [];
$n = 0;
foreach ($menus as $key => $value) {
$n++;
$keyboard_buttons_line[] = [
'text' => $value,
'callback_data' => $key,
];
if ($n % 3 == 0 || count($menus) == $n) {
$keyboard_buttons[] = $keyboard_buttons_line;
$keyboard_buttons_line = [];
}
}
echo "<pre>";
print_r(new InlineKeyboard($keyboard_buttons[0], $keyboard_buttons[1], $keyboard_buttons[2])); //THIS HAVE BUG !!! (I don't know how many argument must be set.)
Metadata
Metadata
Assignees
Labels
No labels