Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>TP3</title>
- </head>
- <body>
- <h1>Chaînes et Tableaux</h1>
- <h2>Les Chaînes</h2>
- <h3>Question 1:</h3>
- <?php
- $identite = array('alain', 'basile', 'David','Edgar');
- $age = array(1,15,35,65);
- $mail = array('moi.meme@gtail.be', 'truc@bruce.zo','caro@caramel.org','trop@monmel.fr');
- function aleatoire($identite, $age, $mail) {
- echo "Je me nomme ";
- echo ucfirst($identite[rand(0,sizeof($identite)-1)])." j'ai ";
- echo $age[rand(0,sizeof($age)-1)]." ans et mon mail est ";
- echo $mail[rand(0,sizeof($mail)-1)]. " du domaine ";
- extraction($mail[rand(0,sizeof($mail)-1)]);
- }
- function extraction($mail) {
- $mydomain = explode('@', $mail);
- $myExtension = explode('.', $mydomain[1]);
- $fdomain = $myExtension[0];
- $extension = $myExtension[1];
- echo $fdomain." avec l'extension ".$extension.'.<br>';
- }
- aleatoire($identite,$age,$mail)
- ?>
- <h3>Question 2:</h3>
- <p>Appliqué à la première question</p>
- <h3>Question 3: </h3>
- <?php
- $people = array("Daniel", "Amandine", "daniel", "Zoé", "Zoé", "Tristan","véronique");
- $fruitpeople = new ArrayObject($people);
- $fruitpeople -> asort();
- foreach ($fruitpeople as $value) {
- echo $value.' ';
- }
- ?>
- <h3>Question 4:</h3>
- <?php
- foreach ($people as $value) {
- $value = ucfirst($value);
- $peopleTemp = array();
- if(in_array($value,$peopleTemp,TRUE)) {
- $peopleTemp[$value] = 1
- } else {
- $peopleTemp[$value] += 1;
- }
- var_dump($peopleTemp);
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement