Code Point
September 10, 2010, 06:51:26 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Geshi Sintax Hilighting Mod Installed. Tens of languages available.
Home
Help
Search
Login
Register
Code Point
>
Server Side
>
PHP
(Moderator:
Web Xman
) >
Return multiple values from a function
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Return multiple values from a function (Read 5127 times)
Max Woofer
Jr. Member
Karma: 0
Offline
Posts: 2
Return multiple values from a function
«
on:
September 23, 2006, 11:57:42 AM »
My PHP function needs to return more than one value. How can I do it?
Logged
Web Xman
Moderator
Jr. Member
Karma: 0
Offline
Posts: 2
Re: Return multiple values from a function
«
Reply #1 on:
September 23, 2006, 12:19:57 PM »
Use an array to return more than one value and unpack it with the list() function:
Code
<?php
function
f
(
)
{
$a
=
1
;
$b
=
'x'
;
return
array
(
$a
,
$b
)
;
}
list
(
$a
,
$b
)
= f
(
)
;
?>
Logged
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Announcements
-----------------------------
=> Announcements
-----------------------------
Client Side
-----------------------------
=> Python
-----------------------------
Server Side
-----------------------------
=> Web Python
=> PHP
-----------------------------
Test
-----------------------------
=> Test
Loading...