Subject: RE: [PHP] Speaking of Global Annoyance
| From: | php3 at developersdesk dot com | Date: | Tue, 19 Dec 2000 05:39:23 +0000 |
| Subject: | Subject: RE: [PHP] Speaking of Global Annoyance | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30987@lists.php.net to get a copy of this message | ||
** Reply to note from "Jonathan Sharp" <webdev@flyerware.com> Mon, 18 Dec 2=
000 18:50:46 -0800
>
> Well...you're correct, you can return them as long as you have a
> fixed number of elements...but if you have a function that returns an
> array with n elements...
That's not so hard either...
Print the contents of an array where you don't know how many
elements there are:
<?
function ReturnArray() {
srand( (double)microtime() * 1000000 );
$Count = rand( 5, 50 );
echo "Creating $Count entries<BR>\n";
for( $I=0; $I<$Count; $I++ ) {
$Array[] = rand( 0, 500 );
}
return $Array;
}
$AnotherArray = ReturnArray();
$Count = 0;
while( list( $Index, $Value ) = each( $AnotherArray )) {
$Count ++;
echo "Count: $Count Index: $Index Value: $Value<BR>\n";
}
?>
You can try it:
http://www.rickwidmer.com/arraytest.php
Or see the source:
http://www.rickwidmer.com/arraytest.phps
Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com