note 26226 modified in function.array by vrana

From: Date: Tue, 17 Aug 2004 13:57:00 +0000
Subject: note 26226 modified in function.array by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79857@lists.php.net to get a copy of this message
In PHP 4.2.3 (and maybe earlier versions) arrays with numeric indexes may be initialized to start at a specific index and then automatically increment the index. This will save you having to write the index in front of every element for arrays that are not zero-based. The code: <?php $a = array ( 21 => 1, 2, 3, ); print '<pre>'; print_r($a); print '</pre>'; ?> will print: <?php Array ( [21] => 1 [22] => 2 [23] => 3 ) ?> --was-- In PHP 4.2.3 (and maybe earlier versions) arrays with numeric indexes may be initialized to start at a specific index and then automatically increment the index. This will save you having to write the index in front of every element for arrays that are not zero-based. The code: $a = array ( 21 => 1, 2, 3, ); print '<pre>'; print_r($a); print '</pre>'; will print: Array ( [21] => 1 [22] => 2 [23] => 3 ) http://php.net/manual/en/function.array.php

« previous php.notes (#79857) next »