Note that there are some explanatory texts on larger screens.

plurals
  1. POletters to touch tone number output
    text
    copied!<p>I tried Googling this but not sure what's the best thing to look for. What I am trying to do is to translate a text input to output the letters of a touch tone phone. For example <code>Hello World</code> would output <code>43550 96153</code>the idea is I'm trying to use the tropo voice api system and want the user to be able to enter their name as touch tone values and match that to their name as numbers in my database. </p> <p>I'm assuming this can be done with a function along the lines of </p> <pre><code>$input= $touchtone_value; $number_two_array (a,b,c); if( $input==in_array($number_two_array)){ $output = '2'; } </code></pre> <p>I'm sure this will work. However, if there is a class out there or a simpler function than to break each letter into number arrays I think that would be a better way to do it. At this point this is a fairly open ended question as I have NO IDEA where to start as the best way to accomplish this. </p> <p><strong>EDIT: I found a solution, not sure it's the best one.</strong> </p> <pre><code> $input = strtolower('HELLO WORLD'); echo 'input: '. $input. "\n"; echo $output = 'output: '. strtr($input,'abcdefghijklmnopqrstuvwxyz', '22233344455566677778889999'); input:hello world output: 43556 96753 </code></pre> <p>Now I just need to find a way to remove white space :) <a href="http://codepad.org/Ieug0Zuw" rel="nofollow noreferrer">http://codepad.org/Ieug0Zuw</a></p> <p>Source: <a href="https://stackoverflow.com/questions/4746183/code-a-number-into-letters">code a number into letters</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload