Jump to content

Javascript Code to PHP Code (Encoding + Decoding)


Cheeky Chino

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.