Parse argv in a PHP CLI Script
Hand-roll CLI parsing using \$argv when getopt is overkill.
Author:
chris
// Language: PHP
<?php
declare(strict_types=1);
array_shift($argv);
$name = $argv[0] ?? 'world';
$count = (int)($argv[1] ?? 1);
for ($i = 0; $i < $count; $i++) {
echo "Hello, $name!\n";
}