An example of when being to clever can come back to bite you…

As part of a test I had to ensure only two alphabetical characters would allowed. So I used `chr(rand(97,122))`; which on a OSX machine is letters a->z. However, this character code sequence (to the best of knowledge NOW) does not translate to other architectures. 4 Hours latter and I replace the above `char()` usage with:
$letterArray = ['a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 's', 't', 'u', 'v', 'w', 'x', 'z',];
$key = \array_rand($letterArray);
...
$letterArray[$key]

After three runs through the applications CI process not once has it failed…yet.

…Here’s hoping it continues to go as planned.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.