1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Quick function transformation...

Discussion in 'PHP' started by WebB3, Dec 17, 2010.

  1. #1
    Hey guys,
    I've been struggling with this for a while and was wondering if you guys could help me turn this function from javascript to php:
    SEMrush
    // CONVERTS *ALL* CHARACTERS INTO ESCAPED VERSIONS.
    function escapeTxt(os){
    	var ns='';
    	var t;
    	var chr='';
    	var cc='';
    	var tn='';
    	for(i=0;i<256;i++){
    		tn=i.toString(16);
    		if(tn.length<2)tn="0"+tn;
    		cc+=tn;
    		chr+=unescape('%'+tn);
    	}
    	cc=cc.toUpperCase();
    	os.replace(String.fromCharCode(13)+'',"%13");
    	for(q=0;q<os.length;q++){
    		t=os.substr(q,1);
    		for(i=0;i<chr.length;i++){
    			if(t==chr.substr(i,1)){
    				t=t.replace(chr.substr(i,1),"%"+cc.substr(i*2,2));
    				i=chr.length;
    			}
    		}
    	ns+=t;
    	}
    	return ns;
    }
    
    Code (markup):
    All help will be deeply appreciated.
    Thank you.
     
    WebB3, Dec 17, 2010 IP
    SEMrush