![]() ![]() They both have the same array, which we get from a get_morse() function (I just split this into a separate function so it makes fewer lines). I've split it into two functions, an encoder and a decoder. *Here's a tiny piece of my encoder to show you how i did thatīasically the same as the decoder, real simple. $seperation = str_replace(".- ","w",$Words) $seperation = str_replace(".- ","v",$Words) $seperation = str_replace(".- ","u",$Words) $seperation = str_replace("- ","t",$Words) $seperation = str_replace("- ","o",$Words) $seperation = str_replace("- ","m",$Words) $seperation = str_replace(".- ","j",$Words) $seperation = str_replace(".- ","a",$Words) $seperation = str_replace("/ "," ",$Words) get the morse, seperate each letter and then decode and echo the outcome I'm new to php so i'm trying to keep it as simple as possible. I tried a bunch of things, but really i don't know what i'm doing and i can't figure it out. So i think i have to first get each letter that was put in the decoder, put them in an array and decode them seperately and then put them back together at the end. That didn't work because it would confuse the morse letters and merge them. I tried to make the decoder the same as my encoder by switching the letters with the codes. The code below is what i have for my decoder. I already got the encoder working but i can't figure out how to make the decoder work. I'm making a php morse encoder and decoder for school.
0 Comments
Leave a Reply. |