I would say that it is good practice to have a βlogicalβ other value that is set as 0 (PHP false) to run, and whenever a function adds this array, add +1 to the logical value, You have a certain way to find out if you need to mess around with the array or not?
That the approach I would use in an object-oriented language in PHP might be more messy, but still I think it's better to have an intentional variable, tracking, rather than trying to parse the array itself. Ideally, if this variable is always an array, set the first value to 0 and use it as a flag:
<?PHP //somewhere in initialization $myArray[0] = 0; ... //somewhere inside an if statement that fills up the array $myArray[0]++; $myArray[1] = someValue; //somewhere later in the game: if($myArray[0] > 0){ //check if this array should be processed or not foreach($myArray as $row){ //start up the for loop if(! $skippedFirstRow){ //$skippedFirstRow will be false the first try $skippedFirstRow++; //now $skippedFirstRow will be true continue; //this will skip to the next iteration of the loop } //process remaining rows - nothing will happen here for that first placeholder row } } ?>
source share