multiplies corresponding elements of two given lists.

0
136
advanced php interview questions

Welcome back to shorltearner.com, we are starting a new series of PHP interview questions for beginners and experienced,so in this post we will see, how to Write a PHP program that multiplies corresponding elements of two given lists.

advanced php interview questions

Also Read :
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

<?php
function multiply_two_lists($x, $y)
 {
    $a = explode(' ',trim($x));
    $b = explode(' ',trim($y));
    foreach($a as $key=>$value) 
 {
        $output[$key] = $a[$key]*$b[$key];
  }
    return implode(' ',$output);
 }
echo multiply_two_lists(("10 12 3"), ("1 3 3"))."\n";
?>

Output

10 36 9