RE: [PHP-DB] removing values from arrays
| From: | Ford, Mike [LSS] | Date: | Thu, 22 May 2003 09:59:18 +0000 |
| Subject: | RE: [PHP-DB] removing values from arrays | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27958@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: John [mailto:mrpeabodi@insightbb.com]
> Sent: 21 May 2003 23:19
>
> ok I've been racking my brain on this for a couple of days.
> What I need to do is after creating an array from a query
> some values are 0. I
> need to be able to "skip" both the value and the key
> frmprinting purposes.
> I have it setup in a multi-demensional array, such as:
> Array
> (
> [0] => Array
> (
> [Department] => IMAX
> [Occurrences] => 1
> [percentage resets of completed] => 0.00
> [completed] => 1
> [In Progress] => 0
> [Waiting for Parts] => 0
> [deferred] => 0
> )
> what I want it as is :
>
> Array
> (
> [0] => Array
> (
> [Department] => IMAX
> [Occurrences] => 1
> [completed] => 1
> )
Try something like:
foreach ($array as $key=>$subarray):
foreach ($subarray as $subkey=>$subval):
if (empty($subval)):
unset($array[$key][$subkey]);
endif;
endforeach;
endforeach;
(untested, so caveat programmor!)
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211