Split String dan Ditampilkan dalam Perulangan dengan PHP


String Awal = a,b,c,d
hasil =
1.a
2.b
3.c
4.d

Script :

<?php 
$string = 'a ,b,c,d';
$array = explode(',', $string); 
$no=1;
foreach($array as $value) {
    echo $no.". ".$value."<br/>"; 
	$no++;
}
?>


sumber : http://stackoverflow.com/questions/10839147/php-iterating-through-a-simple-comma-separated-list

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s