Created
March 3, 2021 16:44
-
-
Save tim-cotten/bd442fb6d02844833d6b757ba1f53ee4 to your computer and use it in GitHub Desktop.
PHP Bugs: Undefined Indexes and More Misspellings (Proof 5)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Simple array of mixed keys and values | |
$arr = array( | |
0 => 'First', | |
1 => 'Second', | |
'Alpha' => 'Greek', | |
'FUN' => true, | |
'00' => 'Last', | |
0.328932 => 'test float', | |
32892.232 => 'test float 2' | |
); | |
$keys = array_keys($arr); | |
foreach ($keys as $key) { | |
echo "{$key} is " . gettype($key) . " => {$arr[$key]}\n"; | |
} | |
// Output: | |
// 0 is integer => test float | |
// 1 is integer => Second | |
// Alpha is string => Greek | |
// FUN is string => 1 | |
// 00 is string => Last | |
// 32892 is integer => test float 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment