Skip to content
RapidFinger — free online typing test

Typing tests

← All programming languages

PHP Coding Practice

Practice typing real code syntax, including brackets, punctuation, and indentation. Snippets are for typing practice only and are never executed.

Functions, arrays, and loops

<?php

declare(strict_types=1);

    function formatName(string $name): string
    {
        return trim($name);
    }

    $names = ['Ada', 'Grace'];
    $formattedNames = array_map('formatName', $names);

    foreach ($formattedNames as $name) {
        echo $name . PHP_EOL;
    }

Transform values with array_map

<?php

$prices = [12, 25, 8];

$withTax = array_map(
    fn (int $price): float => $price * 1.1,
    $prices
);

print_r($withTax);