R4R Team working to provide free of cost for experienced and freshers

Tutorials | Examples|Interview Questions and Answers|Java Tutorials| C Tutorials | C++ Tutorials | Spring Tutorials| Hibernate Tutorials | JSP Tutorials | Servelets Tutorials| C# Tutorials | PHP Tutorials etc , Basics | Download Software | Data Types | Variables | Constant | Storage & Classes | Operators | Decisions Making | Loops | Functions| Numbers | Arrays | Pointers | String | Datastructure | Expressions | Preprocessor Statement | I/O | Exception Handling | OOPs Tutorial | Classes and object |C++ Inheritance Overloading | Polymorphism | Abstraction | Encapsulation | Interfaces | Multithreading etc

PHP Programing language

How can returning list from the Function
Previous Home Next
In this function using for list and create a list for returning from the function.
<html>
<head>
<title>Returning list from Functions  </title>
</head>
<body>
<h1>Returning list from Functions </h1>
<?php
list ($first,$second,$third) = create_list (3);
echo "Here the first list,<br>";
echo "$first, $second, $third <br>";
list ($first,$second,$third,$fourth) =
create_list(4);
echo "Here the second list,<br>";
echo "$first, $second, $third <br>";
function create_list($number)
{
for ($loop_counter = 0; $loop_counter 
	< $number; $loop_counter++)
{
$array[] = $loop_counter;
}
return $array;
}
?>
</body>
</html>

Output:

Previous Home Next