开发者

php substr delete?

开发者 https://www.devze.com 2023-01-29 10:16 出处:网络
I have an game ip in my database, like so: \"271.29.248.23:279开发者_C百科12\" I want the substring to take the last 5 numbers \"27912\" and also i want to delete the \":\".

I have an game ip in my database, like so: "271.29.248.23:279开发者_C百科12"

I want the substring to take the last 5 numbers "27912" and also i want to delete the ":". Is that possible and could someone help me?

And if possible i would like the numbers to be like this so it would be easier...

$ip = "271.29.248.23";
$port = "27912";

Please help me, i need this for a script :(


 list($ip, $port) = explode(":", "$your_string:");


You could also use parse_url, which will handle more cases:

$url = "271.29.248.23:27912";
print_r(parse_url($url));

Prints:

Array
(
    [host] => 271.29.248.23
    [port] => 27912
)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号