Jump to content

Using count with arrays


thirdphase

Recommended Posts

I have created a basic array by pulling values from a database but now need to count how many of the array values are 0.

 

Here is my code so far:

 

$qty_array = array();

$qty_array[0] = $product_row["WF_qty"];

$qty_array[1] = $product_row["SD_qty"];

$qty_array[2] = $product_row["DD_qty"];

$qty_array[3] = $product_row["CD_qty"];

$qty_array[4] = $product_row["PD_qty"];

$qty_array[5] = $product_row["SP_qty"];

$qty_array[6] = $product_row["VS_qty"];

$qty_array[7] = $product_row["RO_qty"];

$qty_array[8] = $product_row["PO_qty"];

 

$qty_count = count($qty_array);

 

This is returning the value 9 as I expected but I am not sure how to change the count function so that I count values that are 0 and ignore the rest.

 

Can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/237152-using-count-with-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.