Advertisement
heru-kzw

Kalkulator Sring combo

Nov 22nd, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.73 KB | None | 0 0
  1. <?php
  2. $kalimat="";
  3. $hasil="";
  4. $proses="";
  5. date_default_timezone_set("Asia/Jakarta");
  6.  
  7.  
  8.  if(isset($_POST["play"])){
  9.     $kalimat=$_POST["kalimat"];
  10.     $proses=$_POST["proses"];
  11.     if($proses=="upper"){$hasil=strtoupper($kalimat);}
  12.    
  13.     else if($proses=="lower"){$hasil=strtolower($kalimat);}
  14.    
  15.     else if($proses=="join"){$hasil=$kalimat." dibuat Oleh Heru....";}
  16.    
  17.     else if($proses=="reverse"){
  18.             $p=strlen($kalimat);
  19.             $hasil="";
  20.                     for($i=1;$i<=$p;$i++){
  21.                     $hasil=$hasil.substr($kalimat,$p-$i,1);}}
  22.                    
  23.     else if($proses=="thumbnail"){$hasil=substr($kalimat,0,1);
  24.                                 $hasil=strtoupper($hasil);
  25.                                 $p=strlen($kalimat);
  26.                                 $hasil2=substr($kalimat,1,$p-1);
  27.                                 $hasil2=strtolower($hasil2);
  28.                                 $hasil=$hasil.$hasil2;}
  29.     else if($proses=="indexof"){$kalimat=strtolower($kalimat);
  30.                                 $cari=strstr($kalimat,"heru");
  31.                                 $p=strlen($cari);
  32.                                 if($p>0){
  33.                                 $hasil="Kalimat tsb ada kata 'heru'";}
  34.                             else{
  35.                                 $hasil="Kalimat tsb Tidak ada kata 'heru'";}}
  36.                                
  37.     else if($proses=="replace"){$hasil=str_replace("saya","heru",$kalimat);}
  38.    
  39.     else if($proses=="array"){$ar=explode(" ",$kalimat);
  40.                             $hasil="";
  41.                             for($i=0;$i<count($ar);$i++){
  42.                             $hasil=$hasil.$ar[$i]." | ";}}
  43.                            
  44.                        
  45.     else if($proses=="count"){$hasil=strlen($kalimat)." karakter";}
  46.     else if($proses=="today"){$hasil=date("Y-m-d");}
  47.    
  48.     else if($proses=="time"){$hasil=date("H:i:s");}
  49.    
  50.    
  51.    
  52.     }
  53. ?>
  54.  
  55.  
  56. <form name="form1" method="post" action="">
  57.   <table width="41%" border="1" align="center" bordercolor="#FFFF00">
  58.     <tr>
  59.       <td colspan="3" align="center" bgcolor="#FF0000"><font color="#ffffff">Kalkulator String Combo Box</font></td>
  60.     </tr>
  61.     <tr>
  62.       <td width="18%" bgcolor="#99FF33">Kalimat</td>
  63.       <td width="3%" align="center" bgcolor="#99FF33">:</td>
  64.       <td width="79%" bgcolor="#99FF33"><label for="kalimat"></label>
  65.       <textarea name="kalimat" cols="35" id="kalimat"><?php echo $kalimat;?></textarea></td>
  66.     </tr>
  67.     <tr>
  68.       <td bgcolor="#99FF33">Hasil</td>
  69.       <td align="center" bgcolor="#99FF33">:</td>
  70.       <td bgcolor="#99FF33"><b><font color="#000000"><?php echo $hasil;?></font></b></td>
  71.     </tr>
  72.     <tr>
  73.       <td bgcolor="#99FF33">Combine</td>
  74.       <td align="center" bgcolor="#99FF33">:</td>
  75.       <td bgcolor="#99FF33"><label for="proses"></label>
  76.         <select name="proses" id="proses">
  77.           <option value="-">&gt;&gt;&gt;Combine&lt;&lt;&lt;</option>
  78.           <option value="upper" <?php if($proses=="upper"){echo"selected";}?>>Upper</option>
  79.           <option value="lower" <?php if($proses=="lower"){echo"selected";}?>>Lower</option>
  80.           <option value="join" <?php if($proses=="join"){echo"selected";}?>>Join</option>
  81.           <option value="reverse" <?php if($proses=="reverse"){echo"selected";}?>>Reverse</option>
  82.           <option value="thumbnail" <?php if($proses=="thumbnail"){echo"selected";}?>>Thumbnail</option>
  83.           <option value="indexof" <?php if($proses=="indexof"){echo"selected";}?>>Index Of</option>
  84.           <option value="replace" <?php if($proses=="replace"){echo"selected";}?>>Replace</option>
  85.           <option value="array" <?php if($proses=="array"){echo"selected";}?>>array</option>
  86.           <option value="today" <?php if($proses=="today"){echo"selected";}?>>Today</option>
  87.           <option value="time" <?php if($proses=="time"){echo"selected";}?>>Time</option>
  88.           <option value="count" <?php if($proses=="count"){echo"selected";}?>>Count</option>
  89.       </select></td>
  90.     </tr>
  91.     <tr>
  92.       <td bgcolor="#FF0000">&nbsp;</td>
  93.       <td bgcolor="#FF0000">&nbsp;</td>
  94.       <td bgcolor="#FF0000"><input name="play" type="submit" id="play" value="Play"></td>
  95.     </tr>
  96.   </table>
  97. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement