Re: Need routine to tell me number of dimensions in array.
| From: | Robert Cummings | Date: | Wed, 17 Mar 2010 01:10:28 +0000 |
| Subject: | Re: Need routine to tell me number of dimensions in array. | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302920@lists.php.net to get a copy of this message | ||
Rene Veerman wrote:
maybe you should be foreach()ing with references? php.net : search "foreach" : As of PHP 5, you can easily modify array's elements by preceding $value with &. This will assign reference instead of copying the value. <?php $arr = array(1, 2, 3, 4); foreach ($arr as &$value) {References in foreach don't work the way you think they work. You will still incur the copy. At least I did when I tested earlier today :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP$value = $value * 2;} // $arr is now array(2, 4, 6, 8) unset($value); // break the reference with the last element ?> This is possible only if iterated array can be referenced (i.e. is variable),