note 56366 deleted from function.array-merge by levim
| From: | levim@php.net | Date: | Mon, 24 Feb 2014 22:54:16 +0000 |
| Subject: | note 56366 deleted from function.array-merge by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198679@lists.php.net to get a copy of this message | ||
Note Submitter: tbs2tbs at hotmail dot com
----
I wanted to share this, it's an small simple script to add things into an array using an
loop/routine.
I use an more developed version to sort msessage's on a forum.
<?php
// Make vars ready
$a=0;
$alltopic = array();
// Start an routine
// 4 is just an example you can use an varible containing
// the number of rows in an databse for example
while ($a < 4)
{
$topic = array($a => "$a");
$alltopic = array_merge ($alltopic, $topic);
$a++;
};
// Put it on screen:
print_r($alltopic);
?>
outputs this :
Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 )