Self generating variables/arrays

From: Date: Sun, 26 Nov 2006 06:19:05 +0000
Subject: Self generating variables/arrays
Groups: php.general 
Request: Send a blank email to php-general+get-245144@lists.php.net to get a copy of this message
Hello; I am writing some code that will format results of a search for display. I need to split an array into several different arrays but I won't know before hand how many, so, I am looking for a way to dynamically generate arrays for this purpose. My present direction is to use the following code: for($i = 0; $i < $c; $i++)
    { eval('$a_'.$i.' = array();'); }
Where '$c' is the derived number of arrays need to hold the pieces of the bigger array. My confusion, though, is; since these are created in the scope of the for loop, I don't know if I can use them elsewhere in the code. The Global statement sends them outside the scope of the function this code is in, or does it? And I'm not even sure I am on the right track. Perhaps someone can say yay or nay on the spot, if not I can go back and do some experimenting. Thanks in advance Jeff K

« previous php.general (#245144) next »