Reputation: 11256
Is there a built-in function in PHP that will return the number of cores on a machine? I’m running on Mac OS X 10.9.3 (Mavericks).
Upvotes: 0
Views: 177
Reputation: 7200
There isn't a php built in function, but you can execute a command to get the result. On OSX 10.9.3 the following will return the number of cores.
$output = '';
$command = "sysctl hw.ncpu | awk '{print $2}'";
exec($command,$output);
echo $output[0];
Upvotes: 1