Using an array returned from a function : Return Value « Functions « PHP

Home
PHP
1.Chart
2.Class
3.Components
4.Cookie Session
5.Data Structure
6.Data Type
7.Date
8.Design Patterns
9.Development
10.DNS
11.Email
12.File Directory
13.Form
14.Functions
15.Graphics Image
16.HTML
17.Language Basics
18.Login Authentication
19.Math
20.MySQL Database
21.Network
22.Operator
23.PDF
24.Reflection
25.Statement
26.String
27.Utility Function
28.Web Services SOAP WSDL
29.XML
PHP » Functions » Return Value 
Using an array returned from a function
 
<?
function myFunction2($meal, $tax, $tip) {
    $tax_amount  = $meal * ($tax / 100);
    $tip_amount  = $meal * ($tip / 100);
    $total_notip = $meal + $tax_amount;
    $total_tip   = $meal + $tax_amount + $tip_amount;

    return array($total_notip, $total_tip);
}

$totals = myFunction2(15.228.2515);

if ($totals[020) {
    print 'The total without tip is less than $20.';
}
if ($totals[120) {
    print 'The total with tip is less than $20.';
}
?>
  
  
Related examples in the same category
1.Function return more than one value
2.Math Function Library
3.A Function That Returns a Value
4.Function Requiring Two Arguments
5.A Function That Returns a Value
6.Functions that return true or false
7.Returning a value from a function
8.Returning an array from a function
9.Returning a list an array from function
10.Returning Values by Reference
11.Returning a Value by Reference
12.Returning by Reference
13.Returning More Than One Value
14.Multiple return statements in a function
15.return multiple values from a function
16.Passing Arguments and Returning Values by Reference
17.User-Defined Function to Determine a Leap Year
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.