note 39334 added to ref.array

From: Date: Sun, 25 Jan 2004 11:27:03 +0000
Subject: note 39334 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-64130@lists.php.net to get a copy of this message
This Functions Checks, if a Array or pieces of the Array empty or not. Complete Tutorial is in German, sry, but i can't spock so good English ;) <?php /** * Diese Funktion überprüft ein ganzes Array auf "vollständigkeit", wobei es drei Arten der zurückgabe kennt. * * 1 : Gibt TRUE bei "unvollständigkeit" zurück und FALSE bei "vollständigkeit" * 2 : Gibt die Anzahl der nicht vollständigen Felder zurück sonst 0 bei "volständigkeit" * 3 : Legt ein neues Array an, indem alle nicht ausgefüllten Felder als das jeweilige Indiez * gespeichert sind, bei "vollständigkeit" FALSE * * Syntax : CheckArray($ARRAY_VAR, INT ART); * * Achtung : Der Standart von ART ist 1, somit muss ART nicht unbedingt angeben werden. * CheckArray(); gibt TRUE zurück, wenn es sich bei der angebenden Variable nicht * um ein Array handelt. * */ function CheckArray($array, $art = 1, $i = 0, $ges = 0) { if(is_array($array)) { foreach($array as $value) { if(empty($value)) { $pos[$i] = $i; } else { $ges++; $pos[$i] = FALSE; } $i++; } if($art == 1) { return (count($array) == $ges ? TRUE : FALSE); } elseif($art == 2) { $res = count($array) - $ges; return ($res == 0 ? 0 : $res); } elseif($art == 3) { $_ = array(); for($k=0; $k<count($array); $k++) { if(is_numeric($pos[$k])) { $_[(count($_) + 1)] = $k; } } return (count($_) == 0 ? FALSE : $_); } } else { return TRUE; } } ?> ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39334 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39334&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39334&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64130) next »