Title: Plural_Forms::execute
Published: November 20, 2017
Last modified: February 24, 2026

---

# Plural_Forms::execute( int $n ): int

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#wp--skip-link--target)

Execute the plural form function.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#parameters)󠁿

 `$n`intrequired

Variable "n" to substitute.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#return)󠁿

 int Plural form value.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#source)󠁿

    ```php
    public function execute( $n ) {
    	$stack = array();
    	$i     = 0;
    	$total = count( $this->tokens );
    	while ( $i < $total ) {
    		$next = $this->tokens[ $i ];
    		++$i;
    		if ( 'var' === $next[0] ) {
    			$stack[] = $n;
    			continue;
    		} elseif ( 'value' === $next[0] ) {
    			$stack[] = $next[1];
    			continue;
    		}

    		// Only operators left.
    		switch ( $next[1] ) {
    			case '%':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 % $v2;
    				break;

    			case '||':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 || $v2;
    				break;

    			case '&&':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 && $v2;
    				break;

    			case '<':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 < $v2;
    				break;

    			case '<=':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 <= $v2;
    				break;

    			case '>':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 > $v2;
    				break;

    			case '>=':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 >= $v2;
    				break;

    			case '!=':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 !== $v2;
    				break;

    			case '==':
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 === $v2;
    				break;

    			case '?:':
    				$v3      = array_pop( $stack );
    				$v2      = array_pop( $stack );
    				$v1      = array_pop( $stack );
    				$stack[] = $v1 ? $v2 : $v3;
    				break;

    			default:
    				throw new Exception( sprintf( 'Unknown operator "%s"', $next[1] ) );
    		}
    	}

    	if ( count( $stack ) !== 1 ) {
    		throw new Exception( 'Too many values remaining on the stack' );
    	}

    	return (int) $stack[0];
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/pomo/plural-forms.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/pomo/plural-forms.php#L261)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/pomo/plural-forms.php#L261-L349)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#related)󠁿

| Used by | Description | 
| [Plural_Forms::get()](https://developer.wordpress.org/reference/classes/plural_forms/get/)`wp-includes/pomo/plural-forms.php` |

Get the plural form for a number.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/plural_forms/execute/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fplural_forms%2Fexecute%2F)
before being able to contribute a note or feedback.