spacer
Web Development Tutorials JAVASCRIPT Tutorials
 Developer Newsletter

Developer Tutorials
AJAX
ASP
CGI & Perl
CSS
Flash
HTML
Illustrator
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML
Miscellaneous


Developer Manuals
Learn HTML
Learn PHP
Learn CSS
Learn Pear
Free White Papers



Scripts Directory
AJAX Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Web Hosting Directory
ASP.NET Hosting
Budget Web Hosting
Dedicated Servers
Linux Web Hosting
Shared Hosting
Small Business Hosting
Windows Web Hosting

Developer Resources
Developer Tools
Developer News
Developer Content
Developer Book Reviews
Survey Software
Photoshop Design Tutorials
Computer Hardware Reviews
Dedicated Servers




JavaScript Equivalent of PHP Explode Function

By Amrit Hallan
2005-10-18
Furl this page

JavaScript equivalent of PHP explode function

In PHP we can easily break a long string into smaller parts by using the explode() function of PHP. In run rime, this function works like this:

$longstring=”Most of the time Amrit is confused — OK, not most of the time”;
$brokenstring=explode(” “, $longstring);

After the execution of the second command the variable $brokenstring is an array such that,

$brokenstring[0]=”Most”
$brokenstring[1]=”of”
$brokenstring[2]=”the”
$brokenstring[3]=”time”
$brokenstring[4]=”Amrit”
$brokenstring[5]=”is”
$brokenstring[6]=”confused”

and so on. So how do we do it in JavaScript. In JavaScript there is a split() function that achieves the same objective, although the syntax is a bit different.

var longstring=”Most of the time Amrit is confused — OK, not most of the time”;
var brokenstring=longstring.split(” “);

Now the variable brokenstring has all those words.



Tutorial Pages:
» JavaScript equivalent of PHP explode function


 | Bookmark Print |   Write For Us
Related Tutorials:
» Striped Tables Using JavaScript
» Opening PDFs in a New Window with JavaScript
» Essential Javascript -- A Javascript Tutorial
» Submit Forms Conditionally using JavaScript
» How to Setup a Randomising Function
» Introduction to JavaScript Tutorial







About the NetVisits, Inc Network | Write For Us | Advertise
Developer Tutorials hosted by HostGator.
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: