Skip to content

Instantly share code, notes, and snippets.

@msng
Created December 2, 2013 05: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 msng/7745635 to your computer and use it in GitHub Desktop.
Save msng/7745635 to your computer and use it in GitHub Desktop.
<?php
$code = '<?php
$array = [
';
for ($i = 0; $i <= 7; $i++) {
$code .= " 'key" . chr($i) . "' => 'value_" . $i . "',\n";
}
$code .= '];
print_r($array);
';
file_put_contents('./keys.php', $code);
<?php
$array = [
'key' => 'value_0',
'key' => 'value_1',
'key' => 'value_2',
'key' => 'value_3',
'key' => 'value_4',
'key' => 'value_5',
'key' => 'value_6',
'key' => 'value_7',
];
print_r($array);
# -*- encoding: utf-8 -*-
require 'pp'
array = {'key' => 'value_0',
'key' => 'value_1',
'key' => 'value_2',
'key' => 'value_3',
'key' => 'value_4',
'key' => 'value_5',
'key' => 'value_6',
'key' => 'value_7'}
pp array
<?php
$keys = [];
for ($i = 0x0; $i < 0x20; $i++) {
$keys[chr($i)] = sprintf('%02s', strtoupper(dechex($i)));
}
print_r($keys);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment