Created
April 26, 2022 22:06
-
-
Save naagaraa/0ccd5b5cdca6ec85412d38ae92f3808c to your computer and use it in GitHub Desktop.
test 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function vocal($string = "") | |
{ | |
$string = str_split(str_replace(" ", "", strtolower($string))); | |
$vocal = "aiueo"; | |
$result = []; | |
foreach ($string as $key => $value) { | |
if (str_contains($vocal, $value)) { | |
array_push($result, $value); | |
} | |
} | |
sort($result); | |
return implode("", $result); | |
} | |
/** | |
* remove vowel char return sort character | |
* | |
* @param array $string | |
* @return void | |
*/ | |
function konsonan($string = "") | |
{ | |
$string = str_split(str_replace(" ", "", strtolower($string))); | |
$vocal = "aiueo"; | |
$result = []; | |
foreach ($string as $key => $value) { | |
if (!str_contains($vocal, $value)) { | |
array_push($result, $value); | |
} | |
} | |
ksort($result); | |
return implode("", $result); | |
} | |
function main($string = "") | |
{ | |
echo vocal($string) . "<br>"; | |
echo konsonan($string) . "<br>"; | |
} | |
main("sample case"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment