Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 两次str_替换_Php_Api - Fatal编程技术网

Php 两次str_替换

Php 两次str_替换,php,api,Php,Api,我真想解决这个问题。 如何使用str_replace两次在命令行中生成类似的内容: /发送消息用户id消息 $to_id = str_replace("/st ","",$text); $to_text = str_replace("/st $to_id ","",$text); if ($text == "/st $to_id $to_text") { apiRequest("sendMessage", array('chat_id' => $to_id ,"text"

我真想解决这个问题。 如何使用str_replace两次在命令行中生成类似的内容:

/发送消息用户id消息

$to_id = str_replace("/st ","",$text);
$to_text = str_replace("/st $to_id ","",$text);
if ($text == "/st $to_id $to_text") {
        apiRequest("sendMessage", array('chat_id' => $to_id ,"text" => "$to_text"));
}
注:
$text
=(命令行中的文本)
$to_id
=(用户id)
$to_text
=(消息)


您正在尝试提取用户id和消息,对吗?用于拆分空格字符上的字符串

$v = explode(' ', $text, 3);
$to_id = $v[1];
$to_text = $v[2];

我很困惑。。。将
$text
中的
“/st”
“/st$to_id”
替换为零。为什么?KIKO软件我也很困惑,我真的不知道我无论如何也不能思考:-什么是
$text
开始时是什么?好的,休息一下,喝杯咖啡,然后在这里阅读PHP手册:chris85 its,$text是message process函数