Jump to content

Matching, with some binary?


FVxSF

Recommended Posts

I'm working on a php interface to get some game server information. So far everything is looking really good, but there are some quirks I'm trying to fix.

 

Let's say I want to get the players from the server. I've been using substr and strpos to get the section I need

 

<?php
$PlayerNamesRaw = substr($PlayerDCopy, strpos($PlayerDCopy, "player_"), (strpos($PlayerDCopy, "score_") - strpos($PlayerDCopy, "player_")));
?>

 

This seems to work well and fast but ever one in a while I get 2 "player_" but the second "player_" is wedged in the name of a player. Look below:

 

player_�� TheGeaRGrindeR�.iNs. Zeropa�T.M.D kaaskop�=LTL= murasaki_imo� Lanimret� SpongeBucket�=HHaz= o-King� s�player_� sgtsrt�

 

You can see it starts off player_ followed by 2 bytes. But towards the end (this is take from a longer name list) you see player_ again. But what I have noticed is that when part of the name is cut you can see the full name after player. But here's my little problem. After I remove player_ and the extra bytes and convery chr(0) to a comma I'm still stuck with that partial name. I can ususally come up with an expression to solve this.. but since I'm working with non-standard characters (those maily being chr(0)), how can I do a preg_replace and replace the data between chr(0) and player_?

 

Going back to the provided string, how can I remove the S between o-King chr(0) AND char(0)player_

 

o-King chr(0) <-- REMOVE ME BETWEEN --> char(0)player_

 

I hope this makes since.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.