Re: Array & unset()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Ken Robinson <kenrbnsn@xxxxxxxxx> wrote:

>At 08:50 PM 9/23/2012, Ron Piggott wrote:
>
>>I am wondering if there is a way to remove from 
>>an array where the value is 0 (“zero”)
>>
>>Array example:
>>
>>$total_points_awarded = array(  1 => 17, 3 => 14, 4 => 0, 5 => 1, 6 =>
>0 );
>>
>>In this example I would like to remove element # 4 and # 6.
>>
>>The “key” ( 1,3,4,5,6 ) represents the 
>>member’s account #.  It is an auto_increment value in a mySQL table
>>The “value” ( 17,14,0,1,0 ) represents their score.
>>
>>The application for this is a list of the top 
>>users.  If someone has 0 points I don’t want to include them.
>>
>>Any thoughts?  Any help is appreciated.
>
>Look at array_filter()  ... http://php.net/array_filter
>
><?php
>$total_points_awarded = array(  1 => 17, 3 => 14, 4 => 0, 5 => 1, 6 =>
>0 );
>print_r(array_filter($total_points_awarded));
>
>
>Ken 
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

Wouldn't it be far easier to do this at the database level in the query?

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux