<?php
/*
   function: to find two or more numbers in the message,  multiply them and return the result
      use an iterative alogrithm to multiply a variable number of values 

   input: (from SMS server)
      code: not used
      text: should contain 2 or more numbers
      from: not used

   author:
      Chris Wallace
      9 Oct 2004

*/

   
$text trim($text);          // to remove trailing whitespace
   
$nums split(" +",$text);  // split the string apart on spaces
                               // + means 1 or more occurances 
   
$prod=1;
   foreach (
$nums as $number){
      
$prod=$prod*$number;      // accumulate the product
   
}
   
$numlist join(" x ",$nums);  // join the numbers with ' x '
   
print "Reply: $numlist = $prod";
    

?>