Skip to main content

Array key ကုိ random ယူျခင္း။

php array ထဲက keys ေတြကုိ random ထုတ္ခ်င္တဲ့အခ်ိန္ေတြရွိမွာပါ။
ေအာက္က ပံုစံအတုိင္းသံုးရင္ ဆင္ေျပပါတယ္။

<?php
            $cities = array(1 => yangon , 2 =>  mandalay , 3 => Pathein , 4 =>  Dawei);
 
            $random_key = array_rand($cities, 1);
             print $random_key;
?>


array_rand ဆိုတဲ့ function သံုးရမွာပါ။
 $cities က ေတာ့ ကုိယ္သံုးခ်င္တဲ့ array ျဖစ္ျပီး 1 က ေတာ့ ဘယ္ႏွစ္ခုဆြဲမလဲလုိ့ ေရြးရတာျဖစ္ပါတယ္။
အေသးစိတ္ကုိ php.net မွာ သြားဖတ္ႏုိင္ပါတယ္။

Source : http://www.homeandlearn.co.uk/php/php6p7.html

Comments

Popular posts from this blog

Lenovo VeriFace Software

ဒီေဆာ့၀ဲကေတာ့ ကြန္ပ်ဴတာ login ၀င္တဲ့အခါမွာ password ရိုက္စရာမလိုပဲ မ်က္နွာေလးျပလိုက္ရံုနဲ့ ေအာ္တို login ၀င္ေပးပါတယ္ .လန္းပါတယ္.webcam တခုေတာ့လိုပါလိမ့္မယ္ laptop ေတြ အတြက္ဆိုရင္ေတာ့ရွယ္ပါပဲ . တျခား brand ေတြမွာလဲအလုပ္လုပ္ပါတယ္ . ေလာေလာဆယ္ကၽြန္ေတာ္က Acer ၾကီးနဲ့ကလိေနတာ :D size : 30.39 MB Click here to download @ mediafire.com Click here to download @ ifile.it Photo credit @ www.tkshare.com Thank u,ko zaw ye` tun :)

Learning English Through Laughter : 3

Mr.Green went to Germany, because he had some work there.He came back last Monday, and his young wife met him at the airport. They walked to their car and passed a tall, pretty air-hostess. Mr. Green said to her , ' Goodbye, Miss Harris, ' and the air-hostess smiled and said, 'Good bye' too. Mrs. Green stopped and looked at the air-hostess .Then she said to her husband, 'How did you know her name?' 'That was easy,'answered Mr.Green. 'The names of the captain and all the screw were on a piece of paper in front of our seates.' 'What was the name of the captain?' Mrs. Green asked with a smile. Mr.Green launged and answered ,'I don't remember any of the other names.' 4/\/\@