Thread: arrays
View Single Post
Old 04-15-2008, 04:16 PM   #1 (permalink)
Evulness
The Contributor
 
Evulness's Avatar
 
Join Date: Apr 2008
Location: Tampa, FL
Posts: 65
Thanks: 6
Evulness is on a distinguished road
Default arrays

i've been having an issue lately, on breaking textarea input from a form, and breaking it down to an array
im writing a script to calculate how much more skill a character needs before they hit their next level. For a MUD i've been playing for 10 years...

so far i have
Code:
<form name="reqs" action="<?php $_SERVER[PHP_SELF]; ?>" method="POST">
<textarea name="text" rows="30" cols="10"></textarea>
<input type="submit" name="submit" value="submit" />
</form>
<?php
$text=$_POST['text'];
preg_match_all('/(([a-z]+ )*[a-z]+): +(\d+)/i', $text, $matches, PREG_SET_ORDER);
foreach($matches as $key=>$value)
    {
        echo $key.': '.$value.'<br />';
    }
    ?>
here is a small clip of the text that will be paste into my textarea box.

Quote:
Primary Magic: 43 80% clear Harness Ability: 46 33% clear
Power Perceive: 43 92% clear Magical Devices: 46 16% clear
Targeted Magic: 33 85% clear Evasion: 43 01% clear
Climbing: 36 52% clear Perception: 30 16% clear
Hiding: 34 37% clear Lockpicking: 4 37% clear
Disarm Traps: 2 05% clear Stalking: 30 93% clear
this is only part of the text... theres probably 40 lines like that...
i'm trying to break each skill down like this

<skill>: <#>
i only need the word(or words) before, and the first non-% number from each "set"

right now... all my script outputs is...
0: Array
1: Array
2: Array
3: Array
4: Array
5: Array
6: Array
7: Array
8: Array
9: Array
10: Array
11: Array

....
any ideas?
Send a message via AIM to Evulness
Evulness is offline  
Reply With Quote