Tools, FAQ, Tutorials:
Returning an Array from a Function in PHP
How To Return an Array from a Function? in PHP?
✍: FYIcenter.com
You can return an array variable like a normal variable using the return statement. No special syntax needed. Here is a PHP script on how to return an array from a function:
<?php function powerBall() { $array = array(rand(1,55), rand(1,55), rand(1,55), rand(1,55), rand(1,55), rand(1,42)); return $array; } $numbers = powerBall(); print("Lucky numbers: ".join(",",$numbers)."\n"); ?>
This script will print:
Lucky numbers: 35,24,15,7,26,15
If you like those numbers, take them to buy a PowerBall ticket.
⇒ Local Variables in a Function in PHP
⇐ Defining an Array Argument as Reference in PHP
2016-12-18, 1327👍, 0💬
Popular Posts:
dev.FYIcenter.com is a Website for software developer looking for software development technologies,...
How to write a policy to set and get custom variables? Here is a policy that sets and gets custom va...
How To Read Data from Keyboard (Standard Input) in PHP? If you want to read data from the standard i...
How to use the JSON to XML Conversion Tool at freeformatter.com? If you want to try the JSON to XML ...
How to login to Azure API Management Publisher Dashboard? If you have given access permission to an ...