After hours of debugging, I found an error in one of my scripts. For saving different event types in a database, I have an array of unique data for each event that can be used to identify the event.
So I basically have some code like
$key = md5(json_encode($data));
to generate a unique key for each event.
Now, in some cases, a value in the $data
array is an integer, sometimes a string (depending on where it comes from - database or URL). That causes the outputs of json_encode()
to be different from each other, though - once including quotes, once not.
Does anybody know a way to "unify" the variable types in the $data
array? That would probably mean converting all strings that only contain an integer value to integer. Anything else I have to take care of when using json_encode()
?