3v4l.org

run code in 300+ PHP versions simultaneously
<?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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
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 ) ) )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
186.74 ms | 408 KiB | 5 Q