FVxSF Posted September 4, 2008 Share Posted September 4, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/122757-matching-with-some-binary/ Share on other sites More sharing options...
effigy Posted September 5, 2008 Share Posted September 5, 2008 What is the exact format of this data (try a hex dump)? What are the black question marks--nulls? Quote Link to comment https://forums.phpfreaks.com/topic/122757-matching-with-some-binary/#findComment-634573 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.