Hi,

I'm new to php (though discovering it's similar to actionscript, which I like), and I've trawled the web looking for answers to my problem. Every time I find an answer that might apply to my situation, I try it and the code doesn't word - nothing shows up on my page. I know it's a really simple piece of code that I need, but I haven't learned enough php to discover it yet.

I know that \d stands for "digits", but I can't work out how to apply it to my code...

So here's an explanation of my problem. I've got a poll on my home page, which is basically a .txt file that repeats a line of various-length text (the poll answers to pick from), a colon, and then a number (which is the number of clicks each poll answer has). Rough example of one line:

XX XXXXX X XXXXX X XXXXXXXXXX XXXXX:6

Now I need to have some php that adds up the number of clicks every poll answer has, then displays it as a total. I've got the code that tells php to get and read the text file ("polldata.txt"), and it works fine, but the part below that says "WHAT_GOES_HERE_SO_PHP_WILL_ADD_UP_MY_NUMBERS?" needs fixed. The segment of code below is part of a larger script, though this section basically displays the results of the poll in a table once a user clicks on "View Stats", or adds the user's vote to the text file once the user selects an answer and votes (all of that script works fine).

Can anyone help? Thank you in advance.



PHP Code:
<?php    
} else {
      if ((isset(
$_POST['submitBtn'])) && (!isset($_POST['statsBtn']))){
          
$count 0;
       foreach (
$answers as $value) {
        if (
$value['text']  == $_POST['polling']) {
            
$answers[$count]['count'] = ((int)$value['count'])+1;
            (int)
$totalCount++;
        }
        ++
$count;
       }
           
    
writeData();
    echo 
nl2br(".\nThanks for your vote!\n.");
    echo 
'   <table width="400">';
    foreach (
$answers as $value) {
        echo 
'<tr><td> '.$value['text'].'</td><td>'.$value['count'].'</td></tr>';
    }
    echo 
'  </table>';
}else {
    if ((isset(
$_POST['statsBtn'])) && (!isset($_POST['submitBtn']))) {
      
writeData();
    echo 
nl2br(".\nCurrent Poll Stats:\n.");
    echo 
'   <table width="400">';
    foreach (
$answers as $value) {
        echo 
'<tr><td> '.$value['text'].'</td><td>'.$value['count'].'</td></tr>';
    }
    echo 
'  </table>';
    }
$numbers preg_match_all("WHAT_GOES_HERE_SO_PHP_WILL_ADD_UP_MY_NUMBERS?"$contents);
$total 0;
foreach (
$numbers as $number) {
    
$total += $number;
}
echo 
$total;
}
}
?>