note 36837 modified in function.array-values by vrana

From: Date: Tue, 17 Aug 2004 14:52:09 +0000
Subject: note 36837 modified in function.array-values by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79926@lists.php.net to get a copy of this message
Just a warning that re-indexing an array by array_values() may cause you to reach the memory limit unexpectly. For example, if your PHP momory_limits is 8MB, and says there's a BIG array $bigArray which allocate 5MB of memory. Doing this will cause PHP exceeds the momory limits: <?php $bigArray = array_values( $bigArray ); ?> It's because array_values() does not re-index $bigArray directly, it just re-index it into another array, and assign to itself later. --was-- Just a warning that re-indexing an array by array_values() may cause you to reach the memory limit unexpectly. For example, if your PHP momory_limits is 8MB, and says there's a BIG array $bigArray which allocate 5MB of memory. Doing this will cause PHP exceeds the momory limits: $bigArray = array_values( $bigArray ); It's because array_values() does not re-index $bigArray directly, it just re-index it into another array, and assign to itself later. http://php.net/manual/en/function.array-values.php

« previous php.notes (#79926) next »