Function return more than one value : Return Value « Functions « PHP






Function return more than one value

<?php
   function retrieve_user_profile() {
      $user[] = "A";
      $user[] = "A@example.com";
      $user[] = "English";
      return $user;
   }
   list($name,$email,$language) = retrieve_user_profile();
   echo "Name: $name, email: $email, preferred language: $language";
?>


           
       








Related examples in the same category

1.Math Function Library
2.A Function That Returns a Value
3.Function Requiring Two Arguments
4.A Function That Returns a Value
5.Functions that return true or false
6.Returning a value from a function
7.Returning an array from a function
8.Returning a list an array from function
9.Returning Values by Reference
10.Returning a Value by Reference
11.Returning by Reference
12.Returning More Than One Value
13.Multiple return statements in a function
14.return multiple values from a function
15.Using an array returned from a function
16.Passing Arguments and Returning Values by Reference
17.User-Defined Function to Determine a Leap Year