No need to use the keyword 'var' in PHP like you are.
I believe you need to look back at the basics. Check out the following link for more details: http://www.php.net/manual/en/language.variables.basics.php
Also, you do not need the ->. You only use this if the left part is an object instance. You would use it to access instance members or static members (however, I'd suggest :: for static members). Check out the following link for more details:
Reference - What does this symbol mean in PHP?
As far as your code goes, remove the 'arrow's and the 'var's. You are echoing 0 because you initialized 'var $dataCounter' as 0.
$arrayOfData = array("Data1", "Data2", "Data3", "Data4", "Data5", "Data6", "Data7", "Data8", "Data9");
$dataCounter = 0;
$setCounter = 1;
foreach($arrayOfData as $row => $value){
$dataCounter++;
if($dataCounter == 3) {
$setCounter++;
$dataCounter = 0;
}
}
Start from there and then continue. Also, for what you are doing a foreach is unnecessary. Instead:
$arrayOfData = array("Data1", "Data2", "Data3", "Data4", "Data5", "Data6", "Data7", "Data8", "Data9");
$setCounter = (sizeOf($arrayOfData))%3; //counts sets of 3