1--TEST-- 2collator_get_sort_key() 3--SKIPIF-- 4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 5<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?> 6<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?> 7--FILE-- 8<?php 9 10/* 11 * Get sort keys using various locales 12 */ 13function sort_arrays( $locale, $data ) 14{ 15 $res_str = ''; 16 17 $coll = ut_coll_create( $locale ); 18 19 foreach($data as $value) { 20 $res_val = ut_coll_get_sort_key( $coll, $value ); 21 $res_str .= "source: ".$value."\n". 22 "key: ".bin2hex($res_val)."\n"; 23 } 24 25 return $res_str; 26} 27 28 29function ut_main() 30{ 31 $res_str = ''; 32 33 // Regular strings keys 34 $test_params = array( 35 'abc', 'abd', 'aaa', 36 'аа', 'а', 'z', 37 '', null , '3', 38 'y' , 'i' , 'k' 39 ); 40 41 $res_str .= sort_arrays( 'en_US', $test_params ); 42 43 // Sort a non-ASCII array using ru_RU locale. 44 $test_params = array( 45 'абг', 'абв', 'жжж', 'эюя' 46 ); 47 48 $res_str .= sort_arrays( 'ru_RU', $test_params ); 49 50 // Sort an array using Lithuanian locale. 51 $res_str .= sort_arrays( 'lt_LT', $test_params ); 52 53 return $res_str . "\n"; 54} 55 56include_once( 'ut_common.inc' ); 57ut_run(); 58?> 59--EXPECT-- 60source: abc 61key: 27292b01070107 62source: abd 63key: 27292d01070107 64source: aaa 65key: 27272701070107 66source: аа 67key: 5c0a0a01060106 68source: а 69key: 5c0a01050105 70source: z 71key: 5901050105 72source: 73key: 0101 74source: 75key: 0101 76source: 3 77key: 1801050105 78source: y 79key: 5701050105 80source: i 81key: 3701050105 82source: k 83key: 3b01050105 84source: абг 85key: 260a161a01070107 86source: абв 87key: 260a161801070107 88source: жжж 89key: 263a3a3a01070107 90source: эюя 91key: 273b3f4501070107 92source: абг 93key: 5c0a161a01070107 94source: абв 95key: 5c0a161801070107 96source: жжж 97key: 5c3a3a3a01070107 98source: эюя 99key: 5d3b3f4501070107 100