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, 2163🔥, 0💬
Popular Posts:
How to dump (or encode, serialize) a Python object into a JSON string using json.dumps()? The json.d...
What is Azure API Management Developer Portal Admin? The Developer Portal Admin is an Azure Web port...
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...
How to build a test service operation to dump everything from the "context.Request" object in the re...
Where to find tutorials on HTML language? I want to know how to learn HTML. Here is a large collecti...