[SOLVED] PHP Explode() equivalent in JavaScript ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
raymedia
Forum Commoner
Posts: 27
Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia

PHP Explode() equivalent in JavaScript ??

Post 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
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

split()
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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);
User avatar
raymedia
Forum Commoner
Posts: 27
Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia

Post by raymedia »

yeppe...works now..thanks a lot guys !!! appreciate it..
Post Reply