Hello I have this function that gives a random value of the array
static public function addProxy($handle, $r, $url)
{
if (!$proxies = TextHelper::commaListArray(ParserConfig::getInstance()->option('proxy_list')))
return;
$randIndex = array_rand($proxies);
$proxy = $proxies[$randIndex];
$proxysused[] .= $proxies[$randIndex];
error_log( print_r( $proxysused, true ) );
curl_setopt($handle, CURLOPT_PROXY, $proxy);
}
This function is called with
static public function initProxy($url)
{
if (self::needSendThroughProxy($url))
\add_action('http_api_curl', array(__CLASS__, 'addProxy'), 10, 3);
}
This function in the same file as addProxy
try
{
newproxy:
$subida++;
CurlProxy::initProxy($url);
$config = ParserConfig::getInstance()->getExtractorConfig();
$product = self::$extractor->extractProduct($url, $config, null, $formats, $httpOptions, $update_mode);
} catch (\Exception $e)
{
if ($subida !== 3) {
error_log($subida);
goto newproxy;
}
$error = $e->getMessage();
$error_code = $e->getCode();
}
This call is in another file than addProxy
As you can see I need to store the variable
$proxies[$randIndex]
in the array variable $proxysused[]
To unset the echoing proxies that were used when calling the function previously.
Currently the code overwrites proxysused and its value always remains at 1 as it does not have variables saved from previous executions.
Any ideas?