Mengurutkan Karakter dengan PHP script menggunakan metode Bubble (Bubble Short)

<html>
<head>
<title>Mengurutkan karakter dengan PHP script by Rido Sandi Atmanto</title></head>
<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<table align="center">
<tr><td colspan="2"><a href="https://ridosandiatmanto.wordpress.com"><h2>Mengurutkan Karakter dengan PHP's script</h2></a></td></tr>
<tr><td  align="center"><b>Masukkan teks<b> :</td><td><input type="text" name="teks"></td><tr>
<tr><td colspan="2" align="center"><input name="submit" type="submit" value="Submit"></td></tr>

<?php
$teks=$_POST['teks'];
echo "<tr><td align=\"center\"><b>Teks</b> : </td><td><h3>".$teks."</h3></td></tr>";

for ($k=0;$k<strlen($teks);$k++){

$A[$k]=ord(substr($teks,$k,1));

}

for ($i=0;$i<strlen($teks);$i++){

for ($k=0;$k<strlen($teks);$k++){

		if (($A[$k])>($A[$k+1])){
		$d=$A[$k];
		$A[$k]=$A[$k+1];
		$A[$k+1]=$d;
				}

		}
}

for ($i=0;$i<=strlen($teks);$i++){
$kar=chr($A[$i]);
$kalimat=$kalimat.$kar;
}

echo "<tr><td align=\"center\"><b>Jumlah Karakter </b> : </td><td><h3>".strlen($teks)."</h3></td></tr>";

echo "<tr><td align=\"center\"> <b>Urutan Karakter</b> : </td><td><h3>".$kalimat."</h3></td></tr>";
?>
</table>
</form>
</body>
<!--Created by Rido Sandi Atmanto-->
</html>

4 Comments to “Mengurutkan Karakter dengan PHP script menggunakan metode Bubble (Bubble Short)”

  1. kalau mengurutkan string pada kalimat itu skriptnya bagaimana ya?

  2. Dneng ra isa dDownload do?????????

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

%d bloggers like this: