WP_Token_Map::to_array()
Exports the token map into an associate array of key/value pairs.
Example:
$smilies->to_array() === array( '8O' => '😯', ':(' => '🙁', ':)' => '🙂', ':?' => '😕', );
Method of the class: WP_Token_Map{}
No Hooks.
Return
Array
. The lookup key/substitution values as an associate array.
Usage
$WP_Token_Map = new WP_Token_Map(); $WP_Token_Map->to_array(): array;
WP_Token_Map::to_array() WP Token Map::to array code WP 6.7.1
public function to_array(): array { $tokens = array(); $at = 0; $small_mapping = 0; $small_length = strlen( $this->small_words ); while ( $at < $small_length ) { $key = rtrim( substr( $this->small_words, $at, $this->key_length + 1 ), "\x00" ); $value = $this->small_mappings[ $small_mapping++ ]; $tokens[ $key ] = $value; $at += $this->key_length + 1; } foreach ( $this->large_words as $index => $group ) { $prefix = substr( $this->groups, $index * ( $this->key_length + 1 ), 2 ); $group_length = strlen( $group ); $at = 0; while ( $at < $group_length ) { $length = unpack( 'C', $group[ $at++ ] )[1]; $key = $prefix . substr( $group, $at, $length ); $at += $length; $length = unpack( 'C', $group[ $at++ ] )[1]; $value = substr( $group, $at, $length ); $tokens[ $key ] = $value; $at += $length; } } return $tokens; }