Horje Website
PHP Returning Array with Functions – Learn Returning array with functions – PHP Code

PHP Returning Array with Functions – Learn Returning array with functions

PHP Returning Array with Functions - Learn Returning array with functions - PHP Code


 
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>PHP Returning Array with Functions</title>
  5. </head>
  6. <body>
  7. <?php
  8. // Defining function
  9. function divideNumbers($dividend, $divisor){
  10. $quotient = $dividend / $divisor;
  11. $array = array($dividend, $divisor, $quotient);
  12. return $array;
  13. }
  14. // Assign variables as if they were an array
  15. list($dividend, $divisor, $quotient) = divideNumbers(10, 2);
  16. echo $dividend . "<br>"; // Outputs: 10
  17. echo $divisor . "<br>"; // Outputs: 2
  18. echo $quotient . "<br>"; // Outputs: 5
  19. ?>
  20. </body>
  21. </html>



Try Your Self ->



Published:
September 25, 2020
Author:
admin
Category:
PHP Basic, PHP Source Code
Views:
18

This article was posted in PHP Basic, PHP Source Code and tagged , , . Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Horje © 2011 - 2023