diff --git a/.idea/sonarlint/issuestore/b/3/b3dc76f2dddfb1a5254e54207056e7abe051447d b/.idea/sonarlint/issuestore/b/3/b3dc76f2dddfb1a5254e54207056e7abe051447d new file mode 100644 index 0000000000000000000000000000000000000000..e0cd4e41322b10fe42b15d4543d4672a52d90569 --- /dev/null +++ b/.idea/sonarlint/issuestore/b/3/b3dc76f2dddfb1a5254e54207056e7abe051447d @@ -0,0 +1,3 @@ + +w php:S6600"5Remove the parentheses from this "require_once" call.(ю8摘晋�1J$90f6c8bc-93bc-4077-bbaa-7c4a2d99c857 +� php:S4833"QReplace "require_once" with namespace import mechanism through the "use" keyword.(ю8知晋�1J$d23cf82e-caac-43b4-b8cf-9b7b260fc815 \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb new file mode 100644 index 0000000000000000000000000000000000000000..aaa01d00aad5acd90d4fe097dd35c3f2365d417a --- /dev/null +++ b/.idea/sonarlint/issuestore/index.pb @@ -0,0 +1,3 @@ + += + app/index.php,b/3/b3dc76f2dddfb1a5254e54207056e7abe051447d \ No newline at end of file diff --git a/.idea/sonarlint/securityhotspotstore/b/3/b3dc76f2dddfb1a5254e54207056e7abe051447d b/.idea/sonarlint/securityhotspotstore/b/3/b3dc76f2dddfb1a5254e54207056e7abe051447d new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/index.pb b/.idea/sonarlint/securityhotspotstore/index.pb new file mode 100644 index 0000000000000000000000000000000000000000..aaa01d00aad5acd90d4fe097dd35c3f2365d417a --- /dev/null +++ b/.idea/sonarlint/securityhotspotstore/index.pb @@ -0,0 +1,3 @@ + += + app/index.php,b/3/b3dc76f2dddfb1a5254e54207056e7abe051447d \ No newline at end of file diff --git a/app/Repository/SlpitKeyValueRepository.php b/app/Repository/SlpitKeyValueRepository.php new file mode 100644 index 0000000000000000000000000000000000000000..738b5c2c373ea4e7e549fe16cd6926f41dcd0de1 --- /dev/null +++ b/app/Repository/SlpitKeyValueRepository.php @@ -0,0 +1,19 @@ +<?php +/** + * 袪邪蟹写械谢褟械褌 写胁褍屑械褉薪褘泄 屑邪褋褋懈胁 薪邪 泻谢褞褔 懈 屑邪褋褋懈胁 蟹薪邪褔械薪泄 + * @param $array array + * @return array + */ +function splitKeyValue($array): array { + $returnableArray = []; + + foreach ($array as $tuple) { + $key = $tuple[0]; + $item = $tuple[1]; + $returnableArray[$key][] = $item; + } + return $returnableArray; +} +{ + +} \ No newline at end of file diff --git a/app/Repository/UniqElementsRepository.php b/app/Repository/UniqElementsRepository.php new file mode 100644 index 0000000000000000000000000000000000000000..763b55b1194436d462dd30899e5b9a57c0856031 --- /dev/null +++ b/app/Repository/UniqElementsRepository.php @@ -0,0 +1,25 @@ +<?php +require_once('SlpitKeyValueRepository.php'); +/** + * 校写邪谢懈褌褜 写褍斜谢懈泻邪褌褘, 芯褋褌邪胁懈胁 褌芯谢褜泻芯 褍薪懈泻邪谢褜薪褘械 蟹薪邪褔械薪懈褟 + * @param array $array + * @return array + */ +function uniqElements(array $array): array { + $splitedArray = splitKeyValue($array); + + $returnableArray = []; + foreach ($splitedArray as $key => $item){ + $item = array_unique($item); + foreach ($item as $oneOfItem){ + $returnableArray[] = [ + [ + $key, + $oneOfItem + ] + ]; + } + } + + return $returnableArray; +} \ No newline at end of file diff --git a/app/index.php b/app/index.php index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..154c16551cbebe9d93ab08cc3e2954eac819ae6e 100644 --- a/app/index.php +++ b/app/index.php @@ -0,0 +1,10 @@ +<?php +require_once('Repository/UniqElementsRepository.php'); + +$arr = [ ['laravel', 'php'], ['codeigniter', 'php'], ['laravel', 'php'], ['c++', 'java'], ]; +$array = uniqElements($arr); +var_dump($array); + + + +