PDA

View Full Version : manipulating strings (PHP)




BRUUUCE
Dec 3, 2007, 01:52 PM
I play a text based game where you attack each other. In this game, there is a newsfeed of all attacks. So if you get a kill shot, you can find it. I'm building a killshot logger/stat site where the user inputs their killshot and my site/database saves it and keeps track of all the data.

here is copy/paste of a kill shot:

Thu Jun 21 09:36:37 PDT 2007 SS Domesday damsel (#94) (MacDuff) PlayerName (#playerNumber) (ClanName) 9deaths / 0foodburned

to help this make sense, it goes, date / typeofattack / (killer) user, userID, clan name / (dead) user, userID, clan name / civilians kills

with the explode function, i can split everything into arrays because all the important info is separated by spaces. So everything was working until i realized the country names (bolded) could have spaces or multiple spaces. is there any way around this? Or am i going have to webfetch the whole newsfeed and grab by the tableIDs. I didn't want to go this route cause i want the user to input their kill shots, not my webpage constantly scanning for them.

hope this makes sense

thanks



toddburch
Dec 3, 2007, 02:20 PM
You could use a regular expression. This is a good application for a "regex".

Todd

BRUUUCE
Dec 3, 2007, 03:27 PM
You could use a regular expression. This is a good application for a "regex".

Todd

i googled regex - looks promising. hopefully i'll be back successful. thank you.