Contents [hide]
Output
a b c
Code examples
JavaScript
1 2 3 4 5 | let str = "a,b,c" ; let array = str.split( "," ); for (i in array) { console.log(array[i]); } |
Perl
1 2 3 4 5 | my $str = "a,b,c" ; my @array = split ( ',' , $str ); foreach $elem ( @array ) { print ( $elem . "\n" ); } |
PHP
1 2 3 4 5 6 | <?php $str = 'a,b,c' ; $array = explode ( ',' , $str ); foreach ( $array as $elem ) { print $elem . "\n" ; } |
Python
1 2 3 4 | str = "a,b,c" array = str .split( "," ) for elem in array: print (elem) |
Ruby
1 2 3 4 5 | str = "a,b,c" array = str.split( "," ) for elem in array print(elem+ "\n" ) end |

Author: Hajime Kurita, CEO/CTO of 1st Class, inc. Search Engineer & Web master
Certificate: AWS SOL Architect, Professional Scrum Master I, Class I IT Engineer(JP national certificate), TOEIC900+, Graduate of Tokyo university
Please follow My English twitter account for updates
IT Relatd service: VPS Ranking