count($instructions) ) { // end of code reached! $reached_end = true; break; } $opcode = $opcodes[$pc - 1]; $operand = $operands[$pc - 1]; $pcs_visited[] = $pc; if ( $opcode == 'nop' ) { ++$pc; } else if ( $opcode == 'acc' ) { $acc += $operand; ++$pc; } else if ( $opcode == 'jmp' ) { $pc += $operand; } } return $reached_end; }