【发布时间】:2017-01-27 05:53:28
【问题描述】:
我需要在等号(=)之后拆分单词,输出如下:
servercreate virtualserver_port=5383 virtualserver_maxclients=5
sid=43 token=hXy4fvF54hMgcZTJkf6f1JcPpvkURMDiOIJ9ERqN virtualserver_port=5383
error id=0 msg=ok
我需要这个 sid=NUMBER 和 token=hXy4... 在 php 中拆分并存储在 mysql 中。
我试着和自己分手:
$sid = split("sid=", $data);
$token = split("token=", $sid[1]);
fclose($stream);
$data1 = ["0" => "$sid[0]", "1" => "$token[1]"];
return $data1;
但作为回报,我收到了这个:
TS3
Welcome to the TeamSpeak 3 ServerQuery interface, type "help" for a list of commands and "help <command>" for information on a specific command.
在 php 中基本上运行了三个带有 ssh2 功能的命令,首先是“telnet IP PORT”,输出为:
TS3
Welcome to the TeamSpeak 3 ServerQuery interface, type "help" for a list of commands and "help <command>" for information on a specific command.
下一个命令是“login ...”输出是:
error id=0 msg=ok
最新的是 ""servercreate ..." 并且输出是 sid=... token=...
【问题讨论】:
-
使用分割函数split('=',关键字);
-
使用explode函数explode('=',keyword);
标签: php sql regex split explode