PHP: Check if 0?

Posted by tarnfeld on Stack Overflow See other posts from Stack Overflow or by tarnfeld
Published on 2010-05-28T13:37:43Z Indexed on 2010/05/28 13:51 UTC
Read the original article Hit count: 168

Filed under:
|
|
|

Hi,

I am using a class which returns me the value of a particular row and cell of an excel spreadsheet. To build up an array of one column I am counting the rows and then looping through that number with a for() loop and then using the $array[] = $value to set the incrementing array object's value.

This works great if none of the values in a cell are 0. The class returns me a number 0 so it's nothing to do with the class, I think it's the way I am looping through the rows and then assigning them to the array... I want to carry through the 0 value because I am creating graphs with the data afterwards, here is the code I have.

// Get Rainfall
$rainfall = array();
for($i=1;$i<=$count;$i++)
{
    if($data->val($i,2) != 'Rainfall') // Check if not the column title
    {
        $rainfall[] = $data->val($i,2);
    }
}

For your info $data is the excel spreadsheet object and the method $data->val(row,col) is what returns me the value. In this case I am getting data from column 2.

Screenshot of spreadsheet http://cl.ly/1Dmy

Thanks! All help is very much appreciated!

© Stack Overflow or respective owner

Related posts about php

Related posts about array