Let's say we have something like this in the database: "Player Jack attacked you and killed 1,000 hustlers, 284,234 bouncers and 0 thugs." Pure text. Would it be possible to make a script that pulls the numbers from the text and makes the variables? Like $deadhustlers = 1000; $deadbouncers = 284234; $deadthugs = 0; They would always be in the same order in the text. I don't really know of any functions that are able to do something. edit: I could also also put some random tags around the numbers like <deadthug>0</deadthug> thugs. If that would make it easier to pull them with another script? I don't want to log the dead "units" separately since they are already in the log text, but I will if it's my last option. What do you think?
IMO the best solution would be to put some tags around the numbers and use preg_match to pull them out.
Obviously xOx is trying to parse an external source (may be a oGame like site), so he won't be able to modify the text. Furthermore, as young coder suggested you can solve it easily with a regular expression: $line = 'Player Jack attacked you and killed 1,000 hustlers, 284,234 bouncers and 0 thugs.'; if (preg_match('/([0-9,]+)[^0-9]+([0-9,]+)[^0-9]+([0-9,]+)/', $line, $result)) { var_dump($result); } PHP: $result will be: Array ( [0] => 1,000 hustlers, 284,234 bouncers and 0 [1] => 1,000 [2] => 284,234 [3] => 0 ) Code (markup):