Page 1 of 1

PHP Explode() equivalent in JavaScript ??

Posted: Fri Jun 18, 2004 9:28 am
by raymedia
can any one let me know if the re is any function in javascript that does the same thing as explode unfciotn in PHP..

thank you

Posted: Fri Jun 18, 2004 9:43 am
by redmonkey
split()

Posted: Fri Jun 18, 2004 11:13 am
by feyd
more specifically:

Code: Select all

var foo = "weee?~#party";
var bar = foo.split('?');
// bar is an array with elements weee and ~#party

// split also takes RegExp objects (regular expression)

var reg = new RegExp("\?~#","g");
var bar2 = foo.split(reg);

// alternately

var bar3 = foo.split(/\?~#/g);

Posted: Fri Jun 18, 2004 12:16 pm
by raymedia
yeppe...works now..thanks a lot guys !!! appreciate it..