Code Point
September 10, 2010, 06:51:26 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Geshi Sintax Hilighting Mod Installed. Tens of languages available.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Return multiple values from a function  (Read 5127 times)
Max Woofer
Jr. Member
*

Karma: 0
Offline Offline

Posts: 2


« 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 Offline

Posts: 2


« 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  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!