দুটি ভেরিয়েবল স্পষ্টভাবে ফেরত দেওয়া যায় না, সেগুলিকে একটি তালিকা/অ্যারে ডেটা স্ট্রাকচারে রেখে ফেরত দেওয়া যেতে পারে৷
উদাহরণ
function factors( $n ) {
// An empty array is declared
$fact = array();
// Loop through it
for ( $i = 1; $i < $n; $i++) {
// Check if i is the factor of
// n, push into array
if( $n % $i == 0 )
array_push( $fact, $i );
}
// Return array
return $fact;
}
// Declare a variable and initialize it
$num = 12;
// Function call
$nFactors = factors($num);
// Display the result
echo 'Factors of ' . $num . ' are: <br>';
foreach( $nFactors as $x ) {
echo $x . "<br>";
} আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেFactors of 12 are: 1 2 3 4 6