By sunslayer on Nov 21, 2009

besides the basic calc functions (+-/) this can also do abbreviations for numbers ex: calc("1m+3k-2") will return "1002998" calc("1.1m+1m") will return "2100000" calc("1.52") will return "3"

this will also calculate powers (^) and modulos (%)

  function calc($a) {
    foreach ($a as $b => $c) {
      if (preg_match($functions,$c)) {
    while ($d<=count($num)) {
      if (preg_match("/./",$sign1)) {
        switch ($sign1) {
          case "+":
          case "-":
          case "*":
          case "/":
          case "^":
            while ($x) {
          case "%":
      }else return $num3;
    }return $num3;
  function iif($if,$T,$F) {
    if ($if) return $T;
    else return $F;
  function rep($num) {
    if (preg_match("/.*\.(.*)/",$num,$len)&&preg_match("/[a-z]/i",$num)) {
    }elseif (preg_match("/.*\.(.*)/",$num,$len)&&!preg_match("/[a-z]/i",$num))
    return $num;
Sign in to comment.
sunslayer   -  Nov 23, 2009

ye it is pretty if u use it for that purpose but the main reason i made this was for calculating like "1m+2.4m" etc.

^Neptune   -  Nov 23, 2009

Good snippet, nice use of case statements.

However it is a tad useless since you can just do

variable = variable + 1
variable += 1

and such.

I would rather just use built in functionalities than having to include a function in every PHP script. Still, nice example though.

sunslayer   -  Nov 21, 2009

lies[quote] Calculator

PHP Code [/quote]

Ghost-writer   -  Nov 21, 2009

nubcake is this mirc or php?

[quote] Calculator mIRC Code [/quote]

Make up your mind.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.