I'm trying to figure out how if the user input like : avg(2,3,6,1)
and then the server will respond with the answer which is : Average of (2,3,6,1) is 3
.
Here is my simple work and got stuck about the next implementation.
if($r['$msg']="avg(".$i")"){ //if message is avg(2,3,6,1)
$i = array($i);
$avg = array_sum($i) / count($i);
echo "<div class='msg'>Server : $avg</div>";
How to make it works? Sorry for the 'noob' code.