小编Tod*_*Tod的帖子

Telegram 内联键盘 PHP

我想知道如何在单击附加的按钮(内联键盘)时更改文本。这是在电报频道中。

像这样的东西,但我的代码如下(不需要更多选项)。

我现在的代码:

$data = [
            'text' => 'choose options yes or no', 
            'chat_id' => '-100234234234'
          ];

$keyboard = array(
    "inline_keyboard" => array(
        array(
            array(
                "text" => "Yes",
                "callback_data" => "myCallbackData"
            ),
            array(
                "text" => "No",
                "callback_data" => "myCallbackData"
            )
        )
    )

file_get_contents("https://api.telegram.org/bot$token/sendMessage?" . http_build_query($data) . "&parse_mode=html&reply_markup=$keyboard");
Run Code Online (Sandbox Code Playgroud)

php api telegram

2
推荐指数
1
解决办法
1万
查看次数

Json encode Arrays value

如何将特定数组键的所有值分配给json值。

$cars = Array ( [0] => Array ( [category] => Most Selling [title] => BMW [price] => 20000 ) [1] => Array ( [category] => Most Selling [title] => Jeep [price] => 15000) [2] => Array ( [category] => Most Selling [title] => Lexus [price] => 18000  ) )

foreach ( $cars as $car) {
     $data = [
    'model' => 'new',
    'company' => $car['title'],
];
}
$json = json_encode($data); 
Run Code Online (Sandbox Code Playgroud)

现在,当我输出$ json时,我得到:

{"model":"new","company":"Lexus"}
Run Code Online (Sandbox Code Playgroud)

为什么不这样分配所有标题值?

{"model":"new","company":"BMW, Jeep, Lexus"}
Run Code Online (Sandbox Code Playgroud)

php arrays api wordpress json

0
推荐指数
1
解决办法
56
查看次数

标签 统计

api ×2

php ×2

arrays ×1

json ×1

telegram ×1

wordpress ×1