Strings

Leading zeroes

// Prints a leading zero if `number` is a single digit.
echo sprintf('%02d', $number);

Include vars in strings

// Using an object.
$my_class = new stdClass();
$my_class->animal_action = 'jumps';

echo "The quick brown fox $my_class->animal_action over the lazy dog.\n";

// Using an array.
$my_array = [
    'animal_action' => 'jumps'
];

echo "The quick brown fox {$my_array['animal_action']} over the lazy dog.\n";

// Using mixed array and object.
$my_class = new stdClass();
$my_class->animal_actions[] = 'jumps';

echo "The quick brown fox {$my_class->animal_actions[0]} over the lazy dog.\n";