<?php
function makeKeyboard($str) {
$kb = array();
$kb_row = explode('|', $str);
foreach($kb_row as $row) {
$buttons = explode(',', $row);
$newrow = array();
foreach($buttons as $text) {
$newrow[] = array('text' => $text);
}
$kb[] = $newrow;
}
return $kb;
}
$test = "button1.1|button2.1,button2.2,button2.3|button3.1|button4.1,button4.2";
$keyboard = makeKeyboard($test);
print_r($keyboard);
?>
- Output for 7.0.0 - 7.0.24, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- Array
(
[0] => Array
(
[0] => Array
(
[text] => button1.1
)
)
[1] => Array
(
[0] => Array
(
[text] => button2.1
)
[1] => Array
(
[text] => button2.2
)
[2] => Array
(
[text] => button2.3
)
)
[2] => Array
(
[0] => Array
(
[text] => button3.1
)
)
[3] => Array
(
[0] => Array
(
[text] => button4.1
)
[1] => Array
(
[text] => button4.2
)
)
)
preferences:
125.48 ms | 405 KiB | 180 Q