Javascript implode : Strings : PHP functions in JavaScript JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » PHP functions in JavaScript » Strings »

 

Javascript implode


Joins array elements placing glue string between items and return one string
Example 1

Running
1.implode(' ', ['Kevin', 'van', 'Zonneveld']);

Could return
1.'Kevin van Zonneveld'
function implode( glue, pieces ) {
    // Joins array elements placing glue string between items and return one string  
    // 
    // version: 812.316
    // discuss at: http://phpjs.org/functions/implode
    // +   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 );
}


HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo PHP functions in JavaScript
» Strings