It is worth noting that array_keys does not maintain the data-type of the keys when mapping them to a new array. This created an issue with in_array and doing a lookup on characters from a string. NOTE: my lookup $array has a full map of numbers and characters - upper and lower - to do an simple faux encryption with.
<?php
$array = array(
'e' => 'ieio'
,'1' => 'one'
,'2' => 'two'
,'0' => 'zero'
);
var_dump($array);
$keys = array_keys($array);
var_dump($keys);
$string = '1e0';
for ($i = 0; $i < strlen($string); $i++) {
if (in_array($string[$i],$keys,'strict')) echo 'dude ';
else echo 'sweet ';
}
?>
Outputs:
array (size=4)
'e' => string 'ieio' (length=4)
1 => string 'one' (length=3)
2 => string 'two' (length=3)
0 => string 'zero' (length=4)
array (size=4)
0 => string 'e' (length=1)
1 => int 1
2 => int 2
3 => int 0
sweet dude sweet
----
expected to see:
dude dude dude