Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Codecademy;
- $learner_one = ["is_correct"=>FALSE, "box"=>["shape"=>"none", "color"=>"none"]];
- $learner_two = ["is_correct"=>TRUE, "box"=>["shape"=>"none", "color"=>"none"]];
- //function for arrays - make permanent changes to $box variable
- function markAnswer($is_answer_correct, &$box){
- if ($is_answer_correct){
- $box["shape"] = "checkmark";
- $box["color"] = "green";
- } else {
- $box["shape"] = "x";
- $box["color"] = "red";
- }
- }
- markAnswer($learner_one["is_correct"], $learner_one["box"]);
- markAnswer($learner_two["is_correct"], $learner_two["box"]);
- print_r($learner_one["box"]);
- print_r($learner_two["box"]);
- function chooseCheckoutLane($items) {
- if ($items <=12) {
- return "express lane";
- }
- else {
- return "regular lane";
- }
- }
- function canIVote($age){
- if ($age>=18){
- return "yes";
- } else {
- return "no";
- }
- }
- // test for each condition
- echo chooseCheckoutLane(20);
- echo chooseCheckoutLane(5);
- echo canIVote(30);
- echo canIVote(16);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement