mysql - Can I paralellize this foreach loop in PHP? -


currently script takes 6 minutes complete.


here's snippet:

$items = getsomeitems(); $results = array();  foreach ($items $index => $value) {     $valuea = getvaluea($value); // 2 minute process.     $valueb = getvalueb($value); // 2 minute process.     $valuec = getvaluec($value); // 2 minute process.     $results[] = array('a' => $valuea, 'b' => $valueb, 'c' => $valuec, ) }  return $results; 

is there way paralellize foreach loop? don't care order in arrays added $results, order them in sql anyways.

can like?

parallel-foreach ($items $index => $value) {     $valuea = getvaluea($value); // 2 minute process.     $valueb = getvalueb($value); // 2 minute process.     $valuec = getvaluec($value); // 2 minute process.     $results[] = array('a' => $valuea, 'b' => $valueb, 'c' => $valuec, ) } 

c# has similar idea in parallel.foreach. i'm looking similar in php.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -