Javascript Equivalent to PHP Explode()
String split method is used to explode (split) a string in JavaScript.
Example
<html> <head> <title>String Split JavaScript</title> </head> <body> <script type="text/javascript"> var str = 'hello,beautiful,world'; var arr = str.split(","); // you may use other characters instead of comma document.write(arr[0] + "<br>"); document.write(arr[1] + "<br>"); document.write(arr[2] + "<br>"); </script> </body> </html>
Output
hello beautiful world