Php = function(){
	return{
		str_replace: function (search, replace, subject) {
		    // http://kevin.vanzonneveld.net
		    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   improved by: Gabriel Paderni
		    // +   improved by: Philip Peterson
		    // +   improved by: Simon Willison (http://simonwillison.net)
		    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
		    // +   bugfixed by: Anton Ongson
		    // +      input by: Onno Marsman
		    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +    tweaked by: Onno Marsman
		    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
		    // *     returns 1: 'Kevin.van.Zonneveld'
		    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
		    // *     returns 2: 'hemmo, mars'
		 
		    var f = search, r = replace, s = subject;
		    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
		 
		    while (j = 0, i--) {
		        if (s[i]) {
		            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
		        }
		    };
		 
		    return sa ? s : s[0];
		}//str_replace
		,substr_count: function ( haystack, needle, offset, length ) {
		    // Returns the number of times a substring occurs in the string  
		    // 
		    // version: 810.1317
		    // discuss at: http://phpjs.org/functions/substr_count
		    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   bugfixed by: Onno Marsman
		    // *     example 1: substr_count('Kevin van Zonneveld', 'e');
		    // *     returns 1: 3
		    // *     example 2: substr_count('Kevin van Zonneveld', 'K', 1);
		    // *     returns 2: 0
		    // *     example 3: substr_count('Kevin van Zonneveld', 'Z', 0, 10);
		    // *     returns 3: false
		    var pos = 0, cnt = 0;
		
		    haystack += '';
		    needle += '';
		    if(isNaN(offset)) offset = 0;
		    if(isNaN(length)) length = 0;
		    offset--;
		
		    while( (offset = haystack.indexOf(needle, offset+1)) != -1 ){
		        if(length > 0 && (offset+needle.length) > length){
		            return false;
		        } else{
		            cnt++;
		        }
		    }
		
		    return cnt;
		}//substr_count
		, strstr: function( haystack, needle, bool ) {
		    // http://kevin.vanzonneveld.net
		    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   bugfixed by: Onno Marsman
		    // *     example 1: strstr('Kevin van Zonneveld', 'van');
		    // *     returns 1: 'van Zonneveld'
		    // *     example 2: strstr('Kevin van Zonneveld', 'van', true);
		    // *     returns 2: 'Kevin '
		 
		    var pos = 0;
		 
		    haystack += '';
		    pos = haystack.indexOf( needle );
		    if( pos == -1 ){
		        return false;
		    } else{
		        if( bool ){
		            return haystack.substr( 0, pos );
		        } else{
		            return haystack.slice( pos );
		        }
		    }
		}//strstr
		 ,in_array: function(needle, haystack, strict) {
		    // http://kevin.vanzonneveld.net
		    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
		    // *     returns 1: true
		    var found = false, key, strict = !!strict;
		    for (key in haystack) {
		        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
		            found = true;
		            break;
		        }
		    }
		    return found;
		}//in_array
		,implode: function ( glue, pieces ) {
		    // http://kevin.vanzonneveld.net
		    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   improved by: Waldo Malqui Silva
		    // *     example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);
		    // *     returns 1: 'Kevin van Zonneveld'
		 
		    return ( ( pieces instanceof Array ) ? pieces.join ( glue ) : pieces );
		}//implode
		,utf8_encode: function ( string ) {
		    // http://kevin.vanzonneveld.net
		    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
		    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   improved by: sowberry
		    // +    tweaked by: Jack
		    // +   bugfixed by: Onno Marsman
		    // +   improved by: Yves Sucaet
		    // +   bugfixed by: Onno Marsman
		    // *     example 1: utf8_encode('Kevin van Zonneveld');
		    // *     returns 1: 'Kevin van Zonneveld'
		 
		    string = (string+'').replace(/\r\n/g, "\n").replace(/\r/g, "\n");
		 
		    var utftext = "";
		    var start, end;
		    var stringl = 0;
		 
		    start = end = 0;
		    stringl = string.length;
		    for (var n = 0; n < stringl; n++) {
		        var c1 = string.charCodeAt(n);
		        var enc = null;
		 
		        if (c1 < 128) {
		            end++;
		        } else if((c1 > 127) && (c1 < 2048)) {
		            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
		        } else {
		            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
		        }
		        if (enc != null) {
		            if (end > start) {
		                utftext += string.substring(start, end);
		            }
		            utftext += enc;
		            start = end = n+1;
		        }
		    }
		 
		    if (end > start) {
		        utftext += string.substring(start, string.length);
		    }
		 
		    return utftext;
		}		
	};//return
}();//Php
