note 38093 added to ref.array

From: Date: Mon, 08 Dec 2003 12:44:19 +0000
Subject: note 38093 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-61630@lists.php.net to get a copy of this message
This function removes "blank" (null) elements from the array provided. <?php function clear_array ( $a ) { if ( $a !== array() ) { $b = array(); foreach ( $a as $key => $value ) { if ( is_array ( $value ) ) { if ( limpiar ( $value ) !== false ) { $b[$key] = clear_array ( $value ); } } elseif ( $value !== '' ) { $b[$key] = $value; } } if ( $b !== array() ) { return $b; } else { return false; } } else { return false; } } ?> for example, some array as this: <?php $a = array ( "sihay" => 'valor', "tambien" => 'otrovalor', "subarray" => array ( "cosa" => 'aqui', "nada" => ''), "otrosub" => array() ); ?> using <?php $b = clear_array ( $a ); ?> will be converted into: <?php $b == array ( "sihay" => 'valor', "tambien" => 'otrovalor', "subarray" => array ( "cosa" => 'aqui') ); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38093 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38093&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38093&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61630) next »