Take the 2-minute tour ×

What's the best way to go about running jobs in a foreach in parallel in PHP? Is there a best practice for this? Thanks

share|improve this question

closed as not constructive by Javier, madth3, TryTryAgain, Yasir Arsanukaev, David Cesarino Apr 3 '13 at 2:56


foreach? what exactly you want to parallelize? –  Your Common Sense Apr 2 '13 at 16:16
Each iteration makes a function call that is time consuming (can take several seconds). Was wanting to run the iterations in parallel. I've been able to do this using shell scripting languages but no idea how to do it in PHP (if it can be done). –  user528451 Apr 2 '13 at 16:18
@hjpotter92 that thread recommends exec but I've heard people say not to use it –  user528451 Apr 2 '13 at 16:21
@user528451 exec is fine if you either don't allow user input into the command, or handle it correctly. exec is an easy way to fire off a background process without waiting for the result. –  datasage Apr 2 '13 at 16:49

2 Answers 2

The answer is simple: Parallel processing as a language feature isn't supported by php

share|improve this answer

php doesn't support threading. The most it offers is forking.

share|improve this answer
