RE: [PHP] Speaking of Global Annoyance
| From: | php3 at developersdesk dot com | Date: | Tue, 19 Dec 2000 02:43:44 +0000 |
| Subject: | RE: [PHP] Speaking of Global Annoyance | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30973@lists.php.net to get a copy of this message | ||
Addressed to: "Jonathan Sharp" <webdev@flyerware.com>
<php-general@lists.php.net>
** Reply to note from "Jonathan Sharp" <webdev@flyerware.com> Mon, 18 Dec 2000
15:51:19 -0800
>
> but it's kinda hard to
> return arrays since you can't just do "return $thearray;" and then on
> the other end "$anarray = somefunction();"
Yes you can.
------------------------------------------------
<?
function ReturnArray() {
$Array = array( 1, 2, 3 );
return $Array;
}
$AnotherArray = ReturnArray();
list( $One, $Two, $Three ) = $AnotherArray;
echo "One: $One Two: $Two Three: $Three<BR>\n";
?>
------------------------------------------------
Returns:
One: 1 Two: 2 Three: 3
function ReturnArray() {
return array( 1, 2, 3 );
}
would do the same thing.
function ReturnComplex() {
return array( array( 'Entry[1][1]',
'Entry[1][2]',
'Entry[1][3]' ),
array( 'Entry[2][1]',
'Entry[2][2]',
'Entry[2][3]' ),
array( 'Entry[3][1]',
'Entry[3][2]',
'Entry[3][3]' ));
}
will work too.
$ReturnValue = ReturnComplex();
echo $ReturnValue[2][3]; // Entry[2][3]
Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com