This code snippet:
$inline_keyboard = new InlineKeyboard([
['text' => 'valueA', 'callback_data' => 'valueA'],
], [
['text' => 'valueB', 'callback_data' => 'valueB'],
]);
produces in my telegramm bot the following inline keyboard:
So far so good... But instead of hardcoding the values, I want to produce the same output with values from an array (database query).
I tried with something like this:
$dbValues = array("valueA", "valueB");
foreach ($dbValues as $value)
{
$inline_keyboard .= new InlineKeyboard([
['text' => "$value", 'callback_data' => "$value"],
]);
}
But this fails... I think because I don't have to run a "new" instance in each iteration?
Thanks for helping!