36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
// Tableau contenant une liste d'emails
|
|
$emails = array(
|
|
"frederic.weis@univ-rennes1.fr",
|
|
"david.gatel@univ-rennes1.fr",
|
|
"mael.gramain@etudiant.univ-rennes1.fr",
|
|
"alice.wonderland@hotmail.com",
|
|
"charlie.brown@example.com",
|
|
"samantha.jones@yahoo.com",
|
|
"david.johnson@example.com"
|
|
);
|
|
|
|
// Tableau contenant les noms de domaines correspondant aux adresses mails
|
|
$domains = array();
|
|
foreach ($emails as $email) {
|
|
$parts = explode("@", $email);
|
|
$domain = $parts[1];
|
|
$domains[] = $domain;
|
|
}
|
|
|
|
// Calcul du pourcentage d'emails proposés par chaque nom de domaine
|
|
$counts = array_count_values($domains);
|
|
$total = array_sum($counts);
|
|
$percentages = array();
|
|
foreach ($counts as $domain => $count) {
|
|
$percentage = ($count / $total) * 100;
|
|
$percentages[$domain] = $percentage;
|
|
}
|
|
|
|
// Affichage des résultats
|
|
echo "Liste d'emails : <br/>" . implode(",<br/>", $emails) . "<br/><br/>";
|
|
echo "Noms de domaines correspondants : " . implode(", ", $domains) . "<br/><br/>";
|
|
foreach ($percentages as $domain => $percentage) {
|
|
echo "Pourcentage d'emails proposés par " . $domain . " : " . round($percentage, 2) . "%<br/>";
|
|
}
|