/** Function : dump()

* Arguments: The data - array,hash(associative array),object

*    The level - OPTIONAL

* Returns  : The textual representation of the array.

* This function was inspired by the print_r function of PHP.

* This will accept some data as the argument and return a

* text that will be a more readable version of the

* array/hash/object that is given.

*/

function dump(arr,level) {

var dumped_text = "";

if(!level) level = 0;



//The padding given at the beginning of the line.

var level_padding = "";

for(var j=0;j<level+1;j++) level_padding += "    ";



if(typeof(arr) == 'object') { //Array/Hashes/Objects

 for(var item in arr) {

  var value = arr[item];

 

  if(typeof(value) == 'object') { //If it is an array,

   dumped_text += level_padding + "'" + item + "' ...\n";

   dumped_text += dump(value,level+1);

  } else {

   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";

  }

 }

} else { //Stings/Chars/Numbers etc.

 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";

}

return dumped_text;

} 



function explode( delimiter, string, limit ) {
    // Splits a string on string separator and return array of components. If limit is positive only limit number of components is returned. If limit is negative all components except the last abs(limit) are returned.  
    // 
    // version: 905.412
    // discuss at: http://phpjs.org/functions/explode
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2 ||
        typeof arguments[0] == 'undefined' ||
        typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === '' ||
        delimiter === false ||
        delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function' ||
        typeof delimiter == 'object' ||
        typeof string == 'function' ||
        typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}
