Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,936 questions

51,873 answers

573 users

How to multiply two lists in PHP

1 Answer

0 votes
function multiply_two_lists($l1, $l2) {
    $arr_l1 = explode(' ', trim($l1));
    $arr_l2 = explode(' ', trim($l2));

    foreach ($arr_l1 as $key => $value) {
        $arr_result[$key] = $arr_l1[$key] * $arr_l2[$key];
    }
    return implode(' ', $arr_result);
}

echo multiply_two_lists(("2 5 6 10"), ("3 5 7 11"));



/*
  run:

  6 25 42 110

 */

 



answered Feb 27, 2019 by avibootz

Related questions

3 answers 166 views
166 views asked Apr 18, 2021 by avibootz
3 answers 269 views
269 views asked Apr 18, 2021 by avibootz
1 answer 195 views
1 answer 207 views
2 answers 107 views
107 views asked Feb 17, 2023 by avibootz
1 answer 130 views
...