Automattic\WooCommerce\Blocks\Utils

CartCheckoutUtils::deep_sort_with_accents()protected staticWC 1.0

Removes accents from an array of values, sorts by the values, then returns the original array values sorted.

Метод класса: CartCheckoutUtils{}

Хуков нет.

Возвращает

Массив. Sorted array.

Использование

$result = CartCheckoutUtils::deep_sort_with_accents( $array );
$array(массив) (обязательный)
Array of values to sort.

Код CartCheckoutUtils::deep_sort_with_accents() WC 9.5.1

protected static function deep_sort_with_accents( $array ) {
	if ( ! is_array( $array ) || empty( $array ) ) {
		return $array;
	}

	$array_without_accents = array_map(
		function ( $value ) {
			return is_array( $value )
				? self::deep_sort_with_accents( $value )
				: remove_accents( wc_strtolower( html_entity_decode( $value ) ) );
		},
		$array
	);

	asort( $array_without_accents );
	return array_replace( $array_without_accents, $array );
}