Final Challenge — Solution Task: Extend buildProfileCard() to also accept an optional "email" key. If present and valid (contains an @ character), append a line "Contact: {email}" to the output; if missing, append "Contact: not provided" instead. Test it with two different simulated $_POST arrays — one with a valid email, one without any email key at all — and echo both results. 0 ? implode(', ', $skills) : 'No skills listed'; $contactLine = (isValidField($email) && str_contains($email, '@')) ? "Contact: " . $email : "Contact: not provided"; return sprintf( "%s\n%s\nSkills: %s\n%s", $name, $role, $skillList, $contactLine ); } // Test 1: a profile with a valid email $withEmail = [ 'name' => 'sam taylor', 'role' => 'Designer', 'skills' => ['Figma', 'CSS'], 'email' => 'sam@example.com' ]; echo buildProfileCard($withEmail); echo "\n\n---\n\n"; // Test 2: a profile with no email key at all $withoutEmail = [ 'name' => 'alex chen', 'role' => 'Backend Engineer', 'skills' => ['PHP', 'MySQL'] ]; echo buildProfileCard($withoutEmail); ?> Output: Sam Taylor Designer Skills: Figma, CSS Contact: sam@example.com --- Alex Chen Backend Engineer Skills: PHP, MySQL Contact: not provided Notes: - $profile['email'] ?? '' safely reads the optional key using the same null coalescing pattern from Chapter 8 — it evaluates to an empty string if "email" was never set at all, rather than triggering an undefined-key warning. - isValidField($email) reuses the exact helper function from helpers.php, keeping the "is this field genuinely present and non-empty" check consistent with how $name is validated elsewhere in the same function. - str_contains($email, '@') is the Chapter 7 string function doing the actual "looks like an email" check — deliberately simple, since full email validation is genuinely more involved and out of scope for this course. - The two test cases exercise both branches of the ternary: a present, valid email appends the real address, while a completely missing key falls all the way through to "Contact: not provided" without any warning or error along the way.