note 43272 modified in function.array-unique by vrana

From: Date: Tue, 17 Aug 2004 14:50:11 +0000
Subject: note 43272 modified in function.array-unique by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79896@lists.php.net to get a copy of this message
Following the code copies of a little function I've wrote that actually works with multidimensional arrays. It also resets the array indexes. <?php if ( !function_exists( "arrayUnique" ) ){ function arrayUnique ( $rArray ){ $rReturn = array (); while ( list( $key, $val ) = each ( $rArray ) ){ if ( !in_array( $val, $rReturn ) ) array_push( $rReturn, $val ); } return $rReturn; } } ?> --was-- Following the code copies of a little function I've wrote that actually works with multidimensional arrays. It also resets the array indexes. if ( !function_exists( "arrayUnique" ) ){ function arrayUnique ( $rArray ){ $rReturn = array (); while ( list( $key, $val ) = each ( $rArray ) ){ if ( !in_array( $val, $rReturn ) ) array_push( $rReturn, $val ); } return $rReturn; } } http://php.net/manual/en/function.array-unique.php

« previous php.notes (#79896) next »