So I have a checkbox that sends to a PHP script. Basically, my checkboxes create an array, of course. Seeing it's one of those $var[]
ones.
So basically, my array will look like this in code:
$vars = array('12345:0','45678:0','78910:0','3434:1','2345:1');
foreach ($vars as $var) {
$vinfo = explode(":", $var);
$vgroup = $vinfo[0];
$vacct = $vinfo[1];
// Various function calls with those variables.
}
Now, as you can see. I am splitting for vinfo and vaccount. In my source. I have two accounts (in this example). Some groups belong to 0 and some groups belong to 1. I want to run the function switchAccount("details");
whenever there's a change in the $vacct
variable in the foreach loop. In this case, it should only switch once (seeing 0 is default).
"Account" ($vacct
) switches vary based on the user input in the checkbox. But (usually) always goes up one number. Again, depending on admin input.
Try this
$vars = array('12345:0','45678:0','78910:0','3434:1','2345:1');
$vacct = '';
foreach ($vars as $var)
{
$vinfo = explode(":", $var);
$vgroup = $vinfo[0];
if($vacct != $vinfo[1])
{
switchAccount("details");
$vacct = $vinfo[1];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With