note 56366 added to function.array-merge
| From: | tbs2tbs at hotmail dot com | Date: | Wed, 31 Aug 2005 18:55:36 +0000 |
| Subject: | note 56366 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94541@lists.php.net to get a copy of this message | ||
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 )
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56366
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56366&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56366&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56366&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56366&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56366&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56366&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56366&report=yes
Search -- http://master.php.net/manage/user-notes.php