1

anyone can help me to convert that function JavaScript to php.

Thank you very much

// DECODES AND UNESCAPES ALL TEXT.
function decodeTxt(s){  
    var s1=unescape(s.substr(0,s.length-1));
    var t='';
    for(i=0;i<s1.length;i++)t+=String.fromCharCode(s1.charCodeAt(i)-s.substr(s.length-1,1));
    return unescape(t);
}

// ENCODES, IN UNICODE FORMAT, ALL TEXT AND THEN ESCAPES THE OUTPUT
function encodeTxt(s){
    s=escape(s);
    var ta=new Array();
    for(i=0;i<s.length;i++)ta[i]=s.charCodeAt(i)+encN;
    return ""+escape(eval("String.fromCharCode("+ta+")"))+encN;
}
Ikaro
  • 11
  • 2
  • Do you mean you want to pass the return results of `encodeTxt()` as data to PHP? Are you using a form, or do you want to use AJAX? –  Jul 30 '13 at 17:57
  • No, what I need is to convert these functions to PHP. Without Encrypt text functions only work with Javascript but I need to pass it to PHP uptade make a table from a database – Ikaro Jul 30 '13 at 18:06
  • You should edit your question. Don't use the word "pass." Use "convert." Readers will understand better. –  Jul 30 '13 at 18:14
  • Sorry, I'm using google to translate – Ikaro Jul 30 '13 at 18:18
  • Where's the php code that doesn't work? – user20232359723568423357842364 Jul 30 '13 at 18:24
  • The code is in JavaScript, not how to do the same function but I work with PHP – Ikaro Jul 30 '13 at 18:27
  • This stackoverflow reference may help you: [http://stackoverflow.com/questions/6058394/unicode-character-in-php-string][1] [1]: http://stackoverflow.com/questions/6058394/unicode-character-in-php-string – detailCode Jul 30 '13 at 18:50

0 Answers0