$value) { if ($key === $firstKey) { $ref = $key; break; } } $branch = end(explode('/', $ref)); $updateType = $data['refUpdateEvent']['refUpdates'][$ref]['updateType']; if ($updateType == 'UPDATE_FAST_FORWARD') { if (array_key_exists($branch, $repo['path'])) { foreach ($repo['path'][$branch] as $path) { file_put_contents($file, $path, FILE_APPEND); file_put_contents($file, $branch, FILE_APPEND); if (chdir($path)) { $cmd = 'sudo -u ' . $user . ' git pull origin ' . $branch; $output = shell_exec($cmd); file_put_contents($file, $output, FILE_APPEND); } } } } } }