Jump to content

Recommended Posts

I have an array called $list that has many rows. There is a number in the "amount" column. How can I look through the array and count the ones that have a number higher than 0 and then echo the total.

 

In short:

Look at the array $list

Count the rows that don't have 0 in the "amount" column.

$newList = sizeof($rows-with-no-0-in-amount-column)

 

Thanks!

 

 

Link to comment
https://forums.phpfreaks.com/topic/190584-help-with-an-array/
Share on other sites

Hey Teamatomic, I can't show the results of print_r here because it's real information (and 100s of rows) but doing so I did discover that it's a multidimensional array.  I've also tried $result= array_count_values ($input_array) with a while loop and got no result. Hmmm. I guess multidimensional arrays are hard to count.

Link to comment
https://forums.phpfreaks.com/topic/190584-help-with-an-array/#findComment-1006273
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.