From 469fea321d60fc40c3be590245be68854e2c415f Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 23 Jun 2018 02:22:49 +0900 Subject: [PATCH] =?UTF-8?q?key,value=20pair=EB=A5=BC=20=EB=B3=B4=EC=A1=B4?= =?UTF-8?q?=ED=95=9C=20=EC=84=9E=EA=B8=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sammo/Util.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/sammo/Util.php b/src/sammo/Util.php index 2b0a3bce..86c944c2 100644 --- a/src/sammo/Util.php +++ b/src/sammo/Util.php @@ -281,6 +281,23 @@ class Util extends \utilphp\util return $dict; } + /** + * key=>value pair를 보존한 섞기 + */ + public static function shuffle_assoc(&$array) { + $keys = array_keys($array); + + shuffle($keys); + + foreach($keys as $key) { + $new[$key] = $array[$key]; + } + + $array = $new; + + return true; + } + /** * 0.0~1.0 사이의 랜덤 float