Javascript Equivalent to PHP Explode()

This is a direct conversion from your PHP code:

//Loading the variable
var mystr="0000000020C90037:TEMP:data";

//Splitting it with : as the separator
var myarr = mystr.split(":");

//Then read the values from the array where 0 is the first
//Since we skipped the first element in the array, we start at 1
var myvar = myarr[1] + ":" + myarr[2];

// Show the resulting value
console.log(myvar);
// 'TEMP:data'

Leave a Comment