In this article, you going to see how to return two arrays in PHP using Array Functions in PHP step by step and in a detailed simple way.
If you are looking for this topic then you are at right place.
Let start with the topic of how to return two arrays in PHP using Array Functions in PHP
You going to see this using simple example, using below code snippet.
Declare the function name calculation.
Define the function with two array with value in it.
You can use multiple array as per your requirement.
It is also possible to pass array value.
In the final step all this array variable passed to return single array.
From the below code snippet you can understand easily.
Check with the below code snippet.
<?php
function calculation(){
$dt1=array('1','2');
$dt2=array('1','2');
return array($dt1,$dt2);
}
$data = calculation();
OUTPUT :
print_r($data[0]);
print_r($data[1]);
?>
Output you will get in the form of two arrays.

Hence, we have done with the topic of returning of two arrays in PHP.
How to return multiple array from function in PHP?
It is similar process to achieve to return multiple array from function in PHP.
As you see in the above code snippet declaration of two arrays inside the function.
Similarly, you can declare multiple arrays and then for returning pass to it arrays.
For better understand check with above code snippet.
How to return multiple arrays in PHP?
To return multiple arrays same process you have to follow as given above.
How to return two arrays from a function in PHP?
Below is complete code snippet to return two arrays from a function in PHP.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</head>
<body>
<div style="background-color:#e5bcbc;" align="center">
<h1>How to return two arrays in PHP</h1>
<?php
function calculation(){
$dt1=array('1','2');
$dt2=array('1','2');
return array($dt1,$dt2);
}
$data=calculation();
echo "OUTPUT : ";
print_r($data[0]);
print_r($data[1]);
?>
</div>
</body>
</html>
PHP Explode: How to Retrieve Multiple Checkbox value from Database in PHP Using Explode
How to insert date in MySQL using PHP
Conclusion :
Use the above code snippet to understand regarding returning in PHP
I hope you like this article and if you think that i have missing something, please comment below.