Php 两次str_替换
我真想解决这个问题。 如何使用str_replace两次在命令行中生成类似的内容: /发送消息用户id消息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"
$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函数