Cheeky Chino Posted August 19, 2009 Share Posted August 19, 2009 Hi Guys, Can someone help me convert the following JAVASCRIPT code into PHP code. <SCRIPT> function decode(encodedString) { var decodedString = ""; for (i = 0; i < encodedString.length; i++) { var character = encodedString.charAt(i); if(/[a-zA-Z]/.test(character)) { var base =(/[A-Z]/.test(character))? 'A':'a' ; decodedString += String.fromCharCode((character.charCodeAt(0) - base.charCodeAt(0) + 39 ) %26 + base.charCodeAt(0)); } else if (/[0-9]/.test(character)) { decodedString += String.fromCharCode((character.charCodeAt(0) - 48 + 15 ) %10 + 48); } else { decodedString += character; } } return decodedString; } document.write(decode('<qvi pynff="pryy5"><c>89 Unyyfgebz Cy<oe />Jrgurevyy Cnex<oe />AFJ, 7619<oe />Nhfgenyvn<oe /></qvi>')); </SCRIPT> I basically want all the above in <?php ?> instead of <script /> If anyone can help translate, thankyou. Link to comment https://forums.phpfreaks.com/topic/170940-javascript-code-to-php-code-encoding-decoding/ Share on other sites More sharing options...
abazoskib Posted August 19, 2009 Share Posted August 19, 2009 why don't you put it into a file called myJS.js for example and do something like this: <?php echo "<script type=\"text/javascript\">"; include('myJS.js'); echo "</script>"; ?> Works for me usually and its easy to maintain. Link to comment https://forums.phpfreaks.com/topic/170940-javascript-code-to-php-code-encoding-decoding/#findComment-901573 Share on other sites More sharing options...
Cheeky Chino Posted August 19, 2009 Author Share Posted August 19, 2009 Cause I need the code in PHP, not in Javascript. Link to comment https://forums.phpfreaks.com/topic/170940-javascript-code-to-php-code-encoding-decoding/#findComment-901587 Share on other sites More sharing options...
trq Posted August 19, 2009 Share Posted August 19, 2009 Cause I need the code in PHP, not in Javascript. If you want someone to do it for you this isn't the place. We have a freelance board. Link to comment https://forums.phpfreaks.com/topic/170940-javascript-code-to-php-code-encoding-decoding/#findComment-901588 Share on other sites More sharing options...
Cheeky Chino Posted August 19, 2009 Author Share Posted August 19, 2009 Well this is the PHP Coding Help page, I could post what I have so far in PHP and get help from there, same thing. Link to comment https://forums.phpfreaks.com/topic/170940-javascript-code-to-php-code-encoding-decoding/#findComment-901606 Share on other sites More sharing options...
trq Posted August 19, 2009 Share Posted August 19, 2009 Well this is the PHP Coding Help page, I could post what I have so far in PHP and get help from there, same thing. If you have problematic code post it along with the description of your problem. Helping someone fix there problem is not the same as doing there work for them. Link to comment https://forums.phpfreaks.com/topic/170940-javascript-code-to-php-code-encoding-decoding/#findComment-901618 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.