H
H
HappyMen2019-06-29 22:21:39
PHP
HappyMen, 2019-06-29 22:21:39

/start how to recognize the command? php?

The user gives a string like /settext какойто очень красивый текст
How to split this string into two parts: /settextand какойто очень красивый текст??

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2019-06-29
@HappyMen

$param = explode(' ', $text, 2);
https://www.php.net/manual/ru/function.explode.php
Example #3

D
DanKud, 2019-06-29
@DanKud

$str = '/settext какойто очень красивый текст';
preg_match_all('/(^.+?)\s(.+)$/', $str, $m);
$command = $m[1][0]; /* /settext */
$text = $m[2][0]; /* какойто очень красивый текст */

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question