Created
August 11, 2016 01:55
Star
You must be signed in to star a gist
Ne garde qu'un seul exemplaire de chaque caractère parmi tous ceux donnés en entrée
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 | |
header('Content-type: text/html; charset=utf-8'); | |
if(isset($_POST['entree'])) | |
{ | |
$car_exists = array(); | |
$string = preg_split('//u', $_POST['entree'], null, PREG_SPLIT_NO_EMPTY); | |
$nb_car_entree = mb_strlen($_POST['entree']); | |
$string_sortie = ""; | |
/*foreach($string as $car) | |
{ | |
if(@$car_exists[$car] == true) | |
{ | |
//echo "Le caractère '$car' existe déjà.<br />"; | |
} | |
else | |
{ | |
$string_sortie .= $car; | |
$car; | |
$car_exists[$car] = true; | |
} | |
}*/ | |
$string_sortie = array_unique($string); | |
$string_sortie = implode("",$string_sortie); | |
} | |
?> | |
<h1>Entrée</h1> | |
<form action="" method="post"> | |
<textarea cols="100" rows="20" name="entree"><?php echo @$_POST['entree']; ?></textarea><br /> | |
<input type="submit"/> | |
</form> | |
<h1>Sortie</h1> | |
<textarea cols="100" rows="20"><?php echo @$string_sortie; ?></textarea> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment