Looking back, it's probably better to remove the duplicates in the foreach statement to make the function more efficient (foreach array_unique($arr) as $item) then just return the values of the merged array.
Congrats on writing some PHP! You're right! I forgot array_rand() returns a random key, I should have put array_rand(array_flip(['L', 'M', 'R']) this would flip the key value pairs (eg. as a JavaScript object {0: 'L', 1: 'M', 2: 'R'} would become {L: 0, M: 1, R: 2}) then return a random key from that array, which would be the letter. This was my first translation, I appreciate the patience and help!
Sorry for the radio silence! I didn't realize I had to confirm my email to comment! Tried several times on a couple of different browsers and clicking send just moved a status bar on the top but never posted the comments. There's no message that indicates you have to confirm your email first. Ended up finding the solution on a GitHub issue from 2016!
I stupidly had the options of left, middle, CENTER for the piper position when generating random tests. I ran the randoms a couple of times it's strange I never came across the issue of it never picking "center". It should be fixed now though!
Ha! Completely missed the fact that MORSE_CODE was defined already. Oops.
Looking back, it's probably better to remove the duplicates in the foreach statement to make the function more efficient (foreach array_unique($arr) as $item) then just return the values of the merged array.
Congrats on writing some PHP! You're right! I forgot
array_rand()
returns a random key, I should have putarray_rand(array_flip(['L', 'M', 'R'])
this would flip the key value pairs (eg. as a JavaScript object {0: 'L', 1: 'M', 2: 'R'} would become {L: 0, M: 1, R: 2}) then return a random key from that array, which would be the letter. This was my first translation, I appreciate the patience and help!Your usage of
array_rand
was also broken (returned index not the letter).I wrote my first ever PHP code to fix it ;-)
... and added output to verify it.
Sorry for the radio silence! I didn't realize I had to confirm my email to comment! Tried several times on a couple of different browsers and clicking send just moved a status bar on the top but never posted the comments. There's no message that indicates you have to confirm your email first. Ended up finding the solution on a GitHub issue from 2016!
I stupidly had the options of left, middle, CENTER for the piper position when generating random tests. I ran the randoms a couple of times it's strange I never came across the issue of it never picking "center". It should be fixed now though!
@Ignium: plz see the issue in the discrouse => your random tests are wrong.
thanks. approved :-)
Please group the tests (and name those tests) more similar to original so I can more easily check the code