inserting decimals in an array with array_push

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
sanaini
Forum Newbie
Posts: 2
Joined: Wed Sep 10, 2008 1:14 pm

inserting decimals in an array with array_push

Post by sanaini »

Hello everyone,
This one has been killing me for a while.
I am creating a pie chart with JPGraphs. I'm inserting minutes to be displayed right now, but I would like to convert them into hours to show. When I do so, it shows 0. I suppose since the number of minutes is less than an hour, and it does not display decimal points.
This is my code snippet


Code: Select all

 
$xdata=array();
$ydata=array();
$xlables=array();
if($num_rows>=1){
$row=mysql_fetch_assoc($result);
do{
        $mins= $row['minutes'];
        $divider = doubleval(60);
        $hrs = $mins/$divider;
        array_push($xdata,$mins);
        array_push($ydata,trim($row['parent_task_name']));
        $name=$rowName['ln'];
} while($row = mysql_fetch_assoc($result)); 
}
 
Can someone please let me know how to fix this. I'm assuming it messes up once it enters the array. Becasue I did an echo of every step and it shows the values right, but once in the array, the chart shows 0.

Thanks a lot,
-Seyed
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: inserting decimals in an array with array_push

Post by josh »

Can you be more specific what is showing 0? Maybe it would help if you cut this down to a more bare bones example, told us what values you were passing to which function ( whcih line are you having problems with? ) and maybe also tell us what value is being output instead
Post Reply