R
R
rejiw562102020-12-27 14:44:25
PHP
rejiw56210, 2020-12-27 14:44:25

How to save php command value?

I use https://github.com/telegrambot/api

Code:

$bot->command('cc', function ($message) use ($bot) {
    $f = #сообщение
    $bot->sendMessage($message->getChat()->getId(), $f);  #Отправка
});


Those. so far a normal echo bot
But I don't know how to make it remember the value after the /cc command
Maybe you can make it remember the data after the space?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2020-12-27
@rejiw56210

If the problem is getting the part of the string after the first space, so below are a couple of solutions:

<?php
$mystring = "The new brave world!"; 
$delimiter = ' ';

echo explode($delimiter, $mystring, 2)[1]; 
echo PHP_EOL;
echo trim(strstr($mystring, $delimiter));
echo PHP_EOL;
echo substr($mystring, strpos($mystring, $delimiter)+1);
echo PHP_EOL;

Here you can test this PHP code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question