Exercises

  1. Create a function that works with two arguments. The first argument should be a username, and the second should be an email address. Use case conversion functions to capitalize the first letter of the username. Convert the email address to lowercase characters and check that it contains the @ sign. If you can’t find the @ character, return false; otherwise, return an array containing the converted arguments. Test the function.

  2. Create an array of doubles and integers. Loop through the array converting each element to a floating-point number with a precision of 2. Right-align the output within a field of 20 characters.

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.