I’ve a simple function as below:
function increment() {
global $num;
$num ++;
}
It works fine.
It’s called upon to increment a variable $num.
I have a similar one for decrement too.
I’m using the count variable as the source for an image number (eg; $num.jpg), and that too works fine.
However, I want the function to limit the count to the number of images stored in that folder.
I’ve an array which I’ve performed sizeof(array) and assigned it to a variable called $numofimgs.
This too works fine.
SO…
my problem is I can’t seem to integrate an IF statement into the function that works. I’ve tried various methods and the function won’t work at all.
example of what I’ve tried;
function increment() {
global $num;
if ($num > $numofimgs) {
$num = 1;
} else {
$num ++;
}
}
My only thought is that the variable $numofimgs maybe needs to be declared as
int $numofimgs
I’m at work now and can’t try it out, but does that sound feasible or is my syntax above screwed up?
Hope someone can help.
Thanks,
John