WP_HTML_Open_Elements::at( int $nth ): WP_HTML_Token|null

Returns the name of the node at the nth position on the stack of open elements, or null if no such position exists.

Description

Note that this uses a 1-based index, which represents the “nth item” on the stack, counting from the top, where the top-most element is the 1st, the second is the 2nd, etc…

Parameters

$nthintrequired
Retrieve the nth item on the stack, with 1 being the top element, 2 being the second, etc…

Return

WP_HTML_Token|null Name of the node on the stack at the given location, or null if the location isn’t on the stack.

Source

public function at( int $nth ): ?WP_HTML_Token {
	foreach ( $this->walk_down() as $item ) {
		if ( 0 === --$nth ) {
			return $item;
		}
	}

	return null;
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.