Solved

php explode like function

Posted on 2004-09-10
3
525 Views
Last Modified: 2008-03-03
Hi!

I am wondering if there is a javascript function like the php explode function www.php.net/function.explode.

Thx in advance
0
Comment
Question by:Professor
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
sajuks earned 50 total points
ID: 12024705
// try the splt function
<script>


 var pizza  = 'piece1 piece2 piece3 piece4 piece5 piece6';
pieces = pizza.split(',')[0].split(' ');
for(var i=0; i<pieces.length-1; i++)
{  alert('pizza-> ' +pieces[i]);}


 var str   = 'one|two|three|four'
pieces = str.split(',')[0].split('|');

for(var i=0; i<pieces.length-1; i++)
{  alert('str :' +pieces[i]);}


</script>
0
 

Author Comment

by:Professor
ID: 12024755
Thx very much... :)
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12024857
Thanks for the points and grade
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question