i want to array push some data to my main array. but it add my push data incorrectly. i have below code.
$customKeyboard = array();
$customKeyboard = [
"inline_keyboard" => [
[["text" => "back ", "callback_data" => "back"]]
]
];
then I do this
$customKeyboard[] = [["text" => "test", "callback_data" => "test"]];
and i want to $customKeyboard[] data will result as below
$customKeyboard = [
"inline_keyboard" => [
[["text" => "back ", "callback_data" => "back"]],
[["text" => "test", "callback_data" => "test"]]
]
];
You have to properly tell the system under what level / hierarchy you want to add the new data
So , change the line
to
So, use the following
See Demo