Does anybody know why the IF condition doesnt work in this code. I make useful comments to clarify the issue. Aby help would be appreciated.
<?php
global $licznik1;
/****************************************FUNCTION 1***********************************/
function zwroc($plik) { //function returns the numer increased by 1 and save it in the file
global $ids;
$zmienna = file($plik);
(int)$zmienna[0];
for ($i=$zmienna[0]; $i<$zmienna[0]+1; $i++) {
}
$otworz = @fopen($plik, 'w+');
if ($otworz) {
rewind ($otworz);
$zapisz = fwrite($otworz, $i);
$zamknij = fclose ($otworz);
return $i;
}
else {
echo 'Nie mogę przeczytać pliku ' . $plik;
exit;
}
}
/****************************************END OF FUNCTION 1*******************************/
/****************************************FUNCTION 2***********************************/
function zwroc1($plik) { //function reads the value from the file and returns it
$zmienna = file($plik);
(int)$zmienna[0];
return $zmienna[0];
}
/****************************************END OF FUNCTION 2*******************************/
$baseUrl = file("baseurl.txt");
//open the file and gets it on the table
$proxyList = file("proxy.txt");
//open the second file and gets it on the table
$ids = file("id.txt");
//open the third file and gets it on the table this is a loop counter
$ids1 = zwroc('ile.txt');
//we must remamber how many times programm has been started we increment this value each time the programm is running and saves it on the external file
for($i=0, $j=count($ids); $i<$j; $i++) //we do loop for each record in the id.txt file
{
/***only for check the variables****/
echo 'Wartosc q dla Ids i to ' . $ids[$ids1] . '<br>'; //the value is OK
echo 'Licznik1 to ' . $licznik1 . '<br>'; //this value is NOT OK due to the fact that CONDITION 1 seems doesnt work (i dont know why)
/***only for check the variables****/
if ($ids1 == '' || $ids1 == 0) {$licznik1=0; echo 'The counter is equal 0';} //CONDITION 0 if the script is running first time and in the file there is no value
if ($ids[$ids1] == '::') { //CONDITION 1 [B]THE KEY POINT THIS CONDITION DOESNT WORK AS I EXPECTED[/B] if we met '::' char we want to call function zwroc and increments the value in the ile1.txt file. The value in this file is used to point on the table element in $baseUrl
$licznik1 = zwroc('ile1.txt');
}
else {
$licznik1 = zwroc1('ile1.txt'); //CONDITION 2 if we dont met '::' char we want to ONLY read the value from the ile1.txt file we DON'T want to increament it, so we call function zwroc1 on the ile1.txt file to read and return the value from the file
}