views:

43

answers:

1

Can anyone convert this RunRev function to a usable PHP function? I'm not an expert when it comes to PHP so I hope somebody helps me...

Here is the RunRev code snippet, -> http://paste-it.net/public/n8a6437/

I hope somebody helps me...

A: 

Looks to me like this would be:

function tankTotal($pData) {
   $tTotal = 0;
   $tMatch = true;
   while ($tMatch) {
     $tMatch = matchChunk($pData, "&cap&:&([0-9]*[0-9])&", $tCap, $tCap1)
     if ($tMatch) {
       for ($i = $tCap; $i <= $tCap1; $i++) {
         $tTotal .= $pData[$i];
         $pData[$i] = '';
       }
     }
   }
   return $tTotal;
}

Depending on, what "add it" means you might want to do

         $tTotal += $pData[$i]; # Increase the number

instead of

         $tTotal .= $pData[$i]; # Concatenate the string
JochenJung