Just a small note so people don't have to look elsewhere
To get the list of processes or find a process by name, use
$proclist = shell_exec('ps -elF') for linux
$proclist = shell_exec('tasklist') for windows
After that, you can use php normal parsing functions to get the pid