Hi friends, Hello, I am French, excuse me for the very bad translation. Here’s my problem. I’ve a script that works under PHP5, but I think that I could easily adapt it to the PHP4, that’s not very hard to make scripts both PHP4 and PHP5 compatible. Unfortunately, I’m not able to manage it correctly and I can’t convert it. Can you help me to make this conversion? Here some explanations (see below): A part of script: <?php class cTypoGenerator { var $keyboard = array( '1' => array( '2', 'q' ), '2' => array( '1', 'q', 'w', '3' ), '3' => array( '2', 'w', 'e', '4' ), '4' => array( '3', 'e', 'r', '5' ), '5' => array( '4', 'r', 't', '6' ), '6' => array( '5', 't', 'y', '7' ), '7' => array( '6', 'y', 'u', '8' ), '8' => array( '7', 'u', 'i', '9' ), '9' => array( '8', 'i', 'o', '0' ), '0' => array( '9', 'o', 'p' ), '-' => array( '0', 'p' ), 'q' => array( '1', '2', 'w', 'a' ), 'w' => array( 'q', 'a', 's', 'e', '3', '2' ), 'e' => array( 'w', 's', 'd', 'r', '4', '3' ), 'r' => array( 'e', 'd', 'f', 't', '5', '4' ), 't' => array( 'r', 'f', 'g', 'y', '6', '5' ), 'y' => array( 't', 'g', 'h', 'u', '7', '6' ), 'u' => array( 'y', 'h', 'j', 'i', '8', '7' ), 'i' => array( 'u', 'j', 'k', 'o', '9', '8' ), 'o' => array( 'i', 'k', 'l', 'p', '0', '9' ), 'p' => array( 'o', 'l', '0' ), 'a' => array( 'z', 's' , 'w', 'q' ), 's' => array( 'a', 'z', 'x', 'd', 'e', 'w' ), 'd' => array( 's', 'x', 'c', 'f', 'r', 'e' ), 'f' => array( 'd', 'c', 'v', 'g', 't', 'r' ), 'g' => array( 'f', 'v', 'b', 'h', 'y', 't' ), 'h' => array( 'g', 'b', 'n', 'j', 'u', 'y' ), 'j' => array( 'h', 'n', 'm', 'k', 'i', 'u' ), 'k' => array( 'j', 'm', 'l', 'o', 'i' ), 'l' => array( 'k', 'p', 'o' ), 'z' => array( 'x', 's', 'a' ), 'x' => array( 'z', 'c', 'd', 's' ), 'c' => array( 'x', 'v', 'f', 'd' ), 'v' => array( 'c', 'b', 'g', 'f' ), 'b' => array( 'v', 'n', 'h', 'g' ), 'n' => array( 'b', 'm', 'j', 'h' ), 'm' => array( 'n', 'k', 'j' ) ); function getWrongKeyTypos( $word ) { $word = strtolower( $word ); $typos = array(); $length = strlen( $word ); echo "<br>Longueur:".$length; for( $i = 0; $i < $length; $i++ ) { $talettre = $word{$i}; echo "<br>(".$talettre.")"; echo "<br>(".$i.")"; if( self::$keyboard($talettre) ) { $tempWord = $word; foreach( self::$keyboard($talettre) as $char ) { $tempWord{$i} = $char; array_push( $typos, $tempWord ); } } } return $typos; } } echo "le formulaire contient " . $_POST['word']; $word = $_POST['word']; $typos = array(); $typos = cTypoGenerator::getWrongKeyTypos( $word ); foreach ($typos as $value){ $sign1.= "$value,"; } echo "sign1 ".$sign1; ?> Code (markup): The part which poses problem to me is this one: if( self::$keyboard($talettre) ) Code (markup): The current result is as follows: only the first letter of my word is analyzed, then the loop stops. And I can’t determine how to make turn this script in php4. Can you help me to resolve this situation? Patrick
While i can't help out with that code particularly, here's a link that gives a list of techniques on how to make your PHP5 code PHP4 compatible. http://wiki.civicrm.org/confluence/display/CRM/Writing+PHP4+Compatible+code