Solved

php explode like function

Posted on 2004-09-10
3
521 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now