Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 98e3780

Browse files
committed
Update documentation with new method implementation
1 parent 3d46fc9 commit 98e3780

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

examples/send-message-with-inlinekeyboard.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,35 @@
2020
// 0
2121
$row = null;
2222

23+
// Choose one of the following 2 methods:
24+
25+
// METHOD 1: all in once with an array construction
26+
$inlineKeyboard = new Markup([
27+
'inline_keyboard' => [
28+
[
29+
['text' => '1', 'callback_data' => 'k=1'],
30+
['text' => '2', 'callback_data' => 'k=2'],
31+
['text' => '3', 'callback_data' => 'k=3'],
32+
],
33+
[
34+
['text' => '4', 'callback_data' => 'k=4'],
35+
['text' => '5', 'callback_data' => 'k=5'],
36+
['text' => '6', 'callback_data' => 'k=6'],
37+
],
38+
[
39+
['text' => '7', 'callback_data' => 'k=7'],
40+
['text' => '8', 'callback_data' => 'k=8'],
41+
['text' => '9', 'callback_data' => 'k=9'],
42+
],
43+
[
44+
['text' => '0', 'callback_data' => 'k=0'],
45+
],
46+
]
47+
]);
48+
49+
50+
// METHOD 2: in parts, working directly with the object
51+
/*
2352
$inlineKeyboard = new Markup();
2453
for ($i = 1; $i < 10; $i++) {
2554
$inlineKeyboardButton = new Button();
@@ -37,7 +66,7 @@
3766
$inlineKeyboardButton->text = '0';
3867
$inlineKeyboardButton->callback_data = 'k=0';
3968
$inlineKeyboard->inline_keyboard[][] = $inlineKeyboardButton;
40-
69+
*/
4170
$sendMessage->disable_web_page_preview = true;
4271
$sendMessage->parse_mode = 'Markdown';
4372
$sendMessage->reply_markup = $inlineKeyboard;

0 commit comments

Comments
 (0)