I want to run this piece of code concurrently. There is a txt file in the directory named as id.txt where all parameters are replace in the Cookie in headers below. If I'm running this by opening 10 cmd tabs then the process gets slow. So please help me how can I run this concurrently or any suggestions by you
$i=trim(file("index.txt")[0])+0;
$id=file("id.txt")[$i];
$idd=preg_replace('/\s+/', '', $id);
file_put_contents("index.txt",$i+1);
echo $idd;
while(true){
$url8 = "https://www.example.com/";
$header= array("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language: en-US,en;q=0.5",
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: 0",
"Cookie: $idd");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url8);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0");
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
$out = curl_exec($ch);
echo "\n";
echo $currentTime = date( 'h i s', time () );
if(preg_match('/done/',$out)){
die(' done');
}
}