|  Please subscribe to the blog if you haven't already

PHP Typo Generation Class

Needing to target typo’s is a common problem but coming up with lists of them is hard to do. I looked around and there were several good tools out there already but none offered the source code so I could use it in other things. I went ahead and wrote a class in PHP to generate common typos.

Check it out here in the free webmaster scripts section.

Typo Types that are created include:

  • striking the wrong key thats near your intended key
  • missing a character when you type
  • a single transposition error
  • and entering a key twice

The keyboard I based this one is the type used for American English and the only included keystrike typoes it generates are those that would make valid domain names. One of these days I am going to add typos based on similiar phonetics.


Like it? Subscribe to the blog if you haven't already
Filed under: Content Creation, General, Tools, Web Technologies — Scott @ March 16, 2006 4:50 pm Sphinn Digg!

9 Comments »
Comment by Eric Unangst
2006-04-04 21:03:18

First off, this code looks great. The problem I’m running into is getting it to display, ie. what HTML are you using to display the contents. I’ve added:

Typo Generator

before your code, but it doesn’t show all the results that you show and shows some strange messages. My sample is here:
http://www.1hs.org/beta/typo.php?word=dell

Thanks!

Eric Unangst
lastname@gmail.com

 
Comment by Eric Unangst
2006-04-04 21:20:05

Ok, so WP “ate my html”. My real questions are “What HTML are you using to display the contents?” and ” Can I get rid of the ‘Array ( [0]‘ that’s showing and show all output as you did?”

Thanks!
Eric Unangst
TechKid.org
lastname@gmail.com

 
Comment by Scott
2006-04-04 21:22:30

Eric your comment had a link so it was put in moderation, awainting my approval, it helps discourage spammers. Your using a print_r which prints out the contents of an array or object. Instead you need to take the array returned and for a foreach on it to iterate over the values.

 
Comment by Eric Unangst
2006-04-04 21:24:38

Ok, here’s the code I was trying to use:
http://www.1hs.org/beta/typo.php.txt

 
Comment by Scott
2006-04-04 21:31:20

Eric check this out:

http://us2.php.net/foreach

You need to use a foreach function to do what you want.

 
Comment by Eric Unangst
2006-04-06 00:57:22

Thanks Scott. I’m still at a loss with the foreach command. I can’t get it to display the results and the most that I could display using foreach (after an hour) was the $word.

But, I’m cutting my losses on that front because I realized that what I was actually trying to do is push all the results into the address bar via a form; typos separated by a ‘+’ (plus) or ‘,’ (comma)… IE typo.php?keyword=dell+ell+dll…
for typos of the word ‘dell’

If you take a peak at:
http://www.1hs.org/beta/typo.php?keyword=dell
you’ll see what (and WHY) I’m trying…. Take a peek at that 8th line.

Thanks again for the help.

BTW, I used your Text2Image form yesterday to create: http://www.1hs.org/beta/fakereceipts/
as a fun ‘proof of concept’ for April 1st.

 
Comment by Eric Unangst
2006-04-06 00:58:42

“Take a peek at that 8th line…”
refers to the updated file at
http://www.1hs.org/beta/typo.php.txt

 
Comment by Alex
2006-05-13 15:54:57

Scott, it seem’s only work on php 5 ?

 
Comment by Scott
2006-05-14 09:28:56

Yeah Alex that came up recently sorry about that I’ll update the entry.

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.