Skip to content

Instantly share code, notes, and snippets.

@nd3w
Last active March 15, 2024 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nd3w/743a04fd3add430c19237c393a5103a9 to your computer and use it in GitHub Desktop.
Save nd3w/743a04fd3add430c19237c393a5103a9 to your computer and use it in GitHub Desktop.
PHP Snippets

Dump all PHP variables

$all_vars = get_defined_vars();
print_r($all_vars);

Create an array for a range (e.g: array with number from 1 to 9)

$number = 9;

for ($i = 1; $i <= $number; ++$i) {
    $array[] = $i;
}

Number to words in Bahasa Indonesia (intl extension needed)

$numberFormatter = new \NumberFormatter("id_ID", \NumberFormatter::SPELLOUT);
echo $numberFormatter->format('1075000');
// Print: satu juta tujuh puluh lima ribu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment