SHARE
TWEET

RandomArray

salahuddien May 31st, 2020 858 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function random_keys($id) {
  2.     $status =array("kawin", "belum kawin", "janda");
  3.     $agama  =array("islam", "kristen", "katolik", "hindu", "budha");
  4.     $pendidikan=array("tk", "sd", "smk", "s1", "s2");
  5.     if($id=="status") {
  6.         $e = array_rand($status);
  7.     } elseif($id=="agama") {
  8.         $d = array_rand($agama);
  9.         $e = $agama[$d];
  10.     } elseif($id=="pendidikan") {
  11.         $d = array_rand($pendidikan);
  12.         $e = $pendidikan[$d];
  13.     }
  14.     return $e;
  15. }
  16.  
  17. random_keys("status") // integer
  18. random_keys("agama") // string
  19. random_keys("pendidikan") //integer
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top