Re: bcadd

From: Date: Fri, 18 Apr 2003 02:42:22 +0000
Subject: Re: bcadd
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-144361@lists.php.net to get a copy of this message
I don't get any errors it just doesn't add anything its always shows 0 Yeah that is the funny thing. I have includes the full script. I didn't have it compiled in at first and then recompiled and added it in along with updating apache. If you can see the colors below the one in red (that are comment out currently) do not work. And ones in Blue do work. So I have NO CLUE why the oens that are within the foreach call don't but the ones outside of it do ;( Kevin <? $TOTAL_HOURS = "0"; $TOTAL_MIN = "0"; $LAST =`/usr/local/bin/radlast -10 arronpam | grep -v "radwtmp begins" | tr "\n" "~" | tr -s "~" | tr "~" "\n"`; $MINUS_SPACE = preg_replace("/[ ]+/"," ", $LAST); $lines = explode("\n",$MINUS_SPACE); print "<TABLE BORDER=1><TR><TD>Username</TD><TD>Port</TD><TD>IP Address</TD><TD>Date</TD><TD>Start</TD><TD>End</TD><TD>Total</TD></TR>"; foreach ($lines as $line) { $ARRAY = split(" ",$line); if ($ARRAY[0] != "") { $USERNAME = $ARRAY[0]; $PORT = $ARRAY[1]; $IP = $ARRAY[2]; $DAY = $ARRAY[3]; $MONTH = $ARRAY[4]; $DATE = $ARRAY[5]; $START = $ARRAY[6]; $END = $ARRAY[8]; $TOTAL = $ARRAY[9]; $TOTAL = preg_replace("/[()]+/"," ", $TOTAL); $TOTAL_SPLIT = split(":",$TOTAL); $HOUR = $TOTAL_SPLIT[0]; $MIN = $TOTAL_SPLIT[1]; $TOTAL_HOURS = $TOTAL_HOURS + $HOUR; // $TOTAL_HOURS = bcadd($HOUR,$TOTAL_HOURS,0); // $TOTAL_MIN = bcadd($TOTAL_MIN,$MIN,0); $TOTAL_MIN = $MIN + $TOTAL_MIN; print "<TR><TD>$USERNAME</TD><TD>$PORT</TD><TD>$IP</TD><TD>$DAY $MONTH $DATE</TD><TD>$START</TD><TD>$END</TD><TD>$HOUR:$MIN</TD>"; } } $MIN_DIV = bcdiv($TOTAL_MIN,60); $YEAH = bcmul($MIN_DIV,60); $YEAH2 = bcsub($TOTAL_MIN,$YEAH); $TOTAL_HOURS=bcadd($MIN_DIV,$TOTAL_HOURS); $TOTAL_MIN = $YEAH2; print "<TR><TD COLSPAN=6 ALIGN=RIGHT>Total time</TD><TD ALIGN=RIGHT COLSPAN=1>$TOTAL_HOURS:$TOTAL_MIN</TD></TR>"; print "</TABLE>"; ?> "Jean-Christian Imbeault" <jc@mega-bucks.co.jp> wrote in message news:3E9F516F.8030202@mega-bucks.co.jp... > Kevin Hoffer wrote: > > > > I can't seem to get it work with 2 variables.I try and use > > $TOTAL = bcadd($TOTAL,$MIN); > > From the documentation: > > In PHP 4, these functions are only available if PHP was > configured with --enable-bcmath. > > Did you compile PHP with --enable-bcmath? > > HTH, > > Jean-Christian Imbeault >

« previous php.general (#144361) next »