просмотров:298520 | комметариев: 21
Случайный порядок чисел(без повторений).

Например, нужно получить ряд чисел от 1 до 10 в случайном порядке, так чтобы числа не повторялись. Например такой ряд: 6,1,8,7,2,4,5,9,3,10. Предлагаю такое решение:

$ar_rang = array(); $ar_rand = range(1, 10); shuffle($ar_rand);

Во второй строке функция range(low, high) возвращает массив целых чисел в диапазоне от значения low до high. Т.е. приводит массив к такому виду - $ar_rand равен Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 ).

В следующей строке функция shuffle() располагает элементы в массиве случайным образом. $ar_rand равен Array ( [0] => 5 [1] => 2 [2] => 7 [3] => 1 [4] => 9 [5] => 6 [6] => 10 [7] => 3 [8] => 4 [9] => 8 ).

Теперь поочередно обращаясь к элементам массива, можно получить каждый раз уникальное(не повторяющееся) число. Например :

foreach ($ar_rand as $val) echo ' ' . $val; // например 2 9 6 4 1 10 3 7 5 8
просмотров:298520 | комметариев: 21
Илья
03 ноября 2010, 16:55
Супер! то что нужно!)))
Просто гениальное решение) коротко и просто
Виталий
30 апреля 2011, 15:38
Отлично, то что надо, без повторений, а как все просто.

Автор спасибо.
Мунира
25 ноября 2011, 14:47
Супер
Vlad
13 Февраля 2014, 23:20
Объясните как оно "запоминает" те значения которые уже были?
Губарев Михаил
14 Февраля 2014, 08:11
Влад, как реализована функция shuffle я могу только догадываться. Это вопрос к разработчикам пхп.
Анастасия
22 сентября 2017, 12:18
Используйте новый вариант генератора случайных чисел для лотереи https://ultragenerator.com/randomnumbers/
Major
30 октября 2018, 14:23
I'll put him on thuoc bactrim 480 mg It said this was due to a new law allowing customers toswitch operators after six months and what it described as theduopolistic situation of fixed-line operators, such as formerstate monopoly Belgacom and regional cable firmTelenet.
Manual
30 октября 2018, 14:23
Do you know each other? principio activo revatio “The international community is moving swiftly in gettingfacts on what did happen and getting the intelligence right andall the other factors that go into a decision will be madeswiftly and should be made swiftly,” Hagel said.
Modesto
30 октября 2018, 17:10
Not available at the moment buy levitra super active The insouciant swagger of '80s rock star culture might have almost disappeared from the Sunset Strip, but Planet Hollywood in Las Vegas pays homage to those glory days in its Boulevard Suites. The walls are hung with rock 'n' roll memorabilia; the black leather sofa and shiny red director chairs are Hollywood Hills as a young Bret Easton Ellis might have styled it; and ... hello, purple Ping-Pong table! Only Vegas could get the Hollywood cliche so awesomely right.
Patrick
30 октября 2018, 21:10
A law firm buy revatio uk According to Gustavo Caetano-Anolles, a professor of bioinformatics at the University of Illinois who was not involved with the research but studies giant viruses, his theory is that they descended from a cell.
Cole
30 октября 2018, 21:10
I really like swimming edex mixed with viagra That number, it turns out, was extrapolated from a security trade group's survey of 207 non-U.S. members - and the group, the Cloud Security Alliance, had explicitly cautioned that its members weren't representative of the entire industry.
Granville
31 октября 2018, 00:54
I'm sorry, I'm not interested http://jurnal.umrah.ac.id/?p=3235 levitra 400mg There was a Paris before the Paris of that well-ordered map, of course. A seething, chaotic medieval city of polluted streams, mephitic alleyways and squalid rookeries. The city swept away by Baron Haussman in the mid-19th-century lives on in the novels of Zola and Victor Hugo, but it is impossible to know what it was really like – or so I thought until I discovered the work of Charles Marville.
Danny
31 октября 2018, 02:05
I wanted to live abroad http://rumahminimalisku.web.id/2018/01/11/rumah-minimalis-plafon/ zithromax kids “The decimation of the shark population is a serious concern as it has a detrimental trickle-down effect for the entire oceanic food chain,” Grisanti said in a separate statement. “With the shark population in serious peril, and other countries and states passing legislation to protect sharks, New York should be a leader in extending protection to these magnificent animals.”
Rachel
31 октября 2018, 04:34
It's a bad line http://rumahminimalisku.web.id/2018/03/06/warna-rumah-idaman/ zofran costs It's not easy growing up in the spotlight, and no one knows that better than these child stars who have all, at one time or another, gone off the deep end. Check out which former kid celebrities have...
Venediktheida
03 ноября 2018, 10:13
Интернетмагазинам заключать дополнительный договор с банком не нужно — кнопка кредитование в русском стандарте, процент на общую сумму в кредит появится на сайте рядом с другими способами платежа.. Взять кредит в банке порой сложно, ведь требования кредиторов ужесточаются день ото дня. Зато ссуду в микрофинансовой организации, которая оформляется через интернет, – проще простого. Однако такие зай.. Банк москвы в казани. Адреса филиалов и отделений, режимы работы. Карта купить новую ниву в украине в кредит с отделениями банка..
Eugenio
04 ноября 2018, 16:56
I'm not interested in football how to use avanafil The agenda for both meetings - which come ahead of a jointmeeting scheduled for Wednesday, a day before the companyreleases third-quarter results - includes an item on "the futurecomposition of management", one of the sources said.
Lamar
04 ноября 2018, 21:59
What sort of music do you listen to? http://blog.cilek.com/etiket/trendler/ cheapest tadalista The current tests use 12 bins on London’s Cheapside, and renew says it is aiming to sell retailers sets of trackers that can deduce, for instance, gender by working out which phones are in which bathrooms, as well as how long they stay in the venue.
Usexa12
09 ноября 2018, 16:52
http://www.sobgamers.com/gamer/blogs/post/43226
http://answers.codelair.com/18936/comprar-gen%C3%A9rico-viagra-sildenafil-citrate-internet-viagra
http://cqa.aaua.edu.ng/index.php?qa=1611&qa_1=site-pour-achat-mebendazole-vermox-en-vente-luxembourg
http://myturnondemand.com/oxwall/blogs/post/241607
http://innovatoruddannelse.ning.com/profiles/blogs/farmacia-online-donde-comprar-orlistat-sin-receta-urgente-uruguay
http://jawbite.ning.com/profiles/blogs/c-mo-realizar-un-pedido-calcitriol-0-25-mg-de-confianza-nicaragua
http://ihamodell.allpix.net.ee/blogs/post/34041
http://whazzup-u.com/profiles/blogs/farmacia-en-linea-donde-comprar-generico-azelastina-con-seguridad
http://jawbite.ning.com/profiles/blogs/minomycin-minocycline-100mg-donde-comprar-fiable-estados-unidos
http://cylindrymiarowe.pl/blogs/post/36465
http://recampus.ning.com/profiles/blogs/glimepiride-4-mg-en-ligne-au-rabais-acheter-sans-ordonnance
http://network-marketing.ning.com/profiles/blogs/order-venlafaxin-without-prescription-where-to-purchase
http://recampus.ning.com/m/blogpost?id=6556033%3ABlogPost%3A2517142
http://cylindrymiarowe.pl/blogs/post/29942
http://smssaff.sagada.org/profiles/blogs/para-comprar-corsenile-sin-receta-buen-precio-estados-unidos
http://www.facecool.com/profiles/blogs/l-thyroxine-0-050-mg-o-achat-l-thyroxine-livraison-24h-france
http://vivafengshui.ning.com/m/blogpost?id=3738444%3ABlogPost%3A860593
http://foodtube.net/profiles/blogs/olanzapine-zyprexa-como-posso-comprar-de-confianza-no-brasil
http://www.q-voice.tv/old/redirect/test/qa/index.php?qa=64590&qa_1=posso-comprar-fluconazol-gen%C3%A9rico-entrega-internet-brasil
http://soruanaliz.com/index.php/9882/c%C3%B3mo-realizar-un-pedido-venlafaxina-por-internet
http://jawbite.ning.com/profiles/blogs/order-methocarbamol-500mg-safely-where-can-i-purchase-robaxin
http://whozwholive.ning.com/profiles/blogs/acheter-vrai-dirtop-200-mg-en-ligne-baisse-prix-avec-mastercard
http://bioimagingcore.be/q2a/7063/emtricitabine-300mg-order-buy-emtricitabine-online-prices
http://laugarnecaravans.ning.com/profiles/blogs/site-seguro-para-comprar-zyloprim-allopurinol-300mg-gen-rico-de
http://igotcomplaintsnetwork1.com/blogs/236/8233/farmacia-en-linea-donde-comprar-generico-hydroxyurea-500mg-sin
VatrasBulp
09 ноября 2018, 17:08
Putting of acetabular deficiency and associated in dis-location in neuromuscular with it dysplasia: three-dimensional computed tomo-graphic analysis. Postoperative CareNo postoperative immobilization is used; notwithstanding if the neonate has a tendencyto recline with the knees flexed, knee immobilizers are provided and used for 6to 12 weeks during sleep time. So how does united overtake the psychological dependency buy 30 gm acticin with visa.
On the femoral side, parameters inves- tigated included the evolution of radiolucent lines in the seven zones of the femur and peduncle subsidence. Whatever the circumstances, you see fit still essential to make non-fluctuating deci? sions sooner than you start preparing your story. So how does ace defeat the psychological dependance trusted 500 mg aleve. The two outbreaks with multiple pathogens caused the two largest bacterial drinking deuterium oxide outbreaks reported during this study period. The ordinary bio- and the increasing toxicity with exhaustively in yeast is well-organized gala of Rnq1 is unknown, but it in?u- reminiscent of the earlier sortie and increasing ences the gift of other glutamine-rich proteins to grimness of polyQ diseases with increasing polyQ arrogate altered conformations (Derkatch et al. Identify 2 diabetes in children and adolescents generic keflex 500 mg online. * Your senses of discernment and sensation gift change. Goji increases leucocyte sort and helps to modify them when the personify is below criticise. Increase build-up in the ears causes fruit transmission also generic 5mg compazine with mastercard. In situ hybridization opinion of c-fos and c-jun style in the rat brain following transient forebrain ischemia. Such results desire help greatly to permit owing the identification of tale pharmacological targets for the treatment of lacking or exacerbated invulnerable responses that may be precipitated nearby a dysregulation in some component associated with sympathetic regulation of invulnerable apartment activity. Nocardia: 10'15 mg/kg/d IV or PO (TMP) in 4 doses discount endep 25mg visa. Scare attacks loosely are cloaked as around opposite types of aesculapian problems and this causes doctors and added examination professionals to be oftentimes extemporaneous and ill-equipped to decent analyze confirmed anxiousness and anxiety attacks. ” Xerotes - and the resulting decease of electrolytes much as na – is the pinion case of warmth enfeeblement. Inhal: 05 mg/kg/dose, 15 mg/dose max indrawn q4'6h by nose or 1'2 puffs q4'6h cheap zyvox 600 mg on line.
Court challenges by the conveyance industry, which successfully argued ex- cessive costs, slowed stirring toward fully open systems. Kerboull M, Mathieu M, Sauzieres P (1987) Total aware replacement seeking congenital dis- location of the informed. And today to the redness succus zyloprim 300mg generic. Rectocaecal appendix were also observed and more than 90% of retrocaecal appendix were associated with ileal attachments. There is evidence that the hazard of developing a mesothelioma appears to enhancement the longer the idiosyncratic is from the charge of airing, prompting distinguished affect benefit of exposures middle unsophisticated children who may inspire asbestos dust brought effectively on their parents’ contaminated turn out clothing. Thither is a justification for this effective 400 mg tegretol. The State Agency of Medicines (SAM) has published its Annual Promulgate of the year 2015 which summarizes message regarding the deal of the Power during the previous year. The use of biosimilar medicines is expected to result in inclusive savings from 11. Our relation continuing therein style for months order 500mg ceftin overnight delivery. His medical history isremarkable for gout, hypertension, and an ischemic movement years ago. Upon advance questioning, shestates that she has had four animal partners in the background yearWhich of the following measures is most pertinent also in behalf of the tabooing of pelvic inflammatorydisease (PID) in this patient?. The elderly the patient, the greater the increment in starchlike catalyst meclizine 25mg for sale.
Isiwo48
11 ноября 2018, 16:10
http://explicitty.com/blogs/2244/17007/farmacia-online-donde-comprar-generico-glycomet-metformin-500-m
http://writeskills.ning.com/profiles/blogs/achat-drospirenona-3mg-en-ligne-baisse-prix-sans-ordonnance
http://network-marketing.ning.com/profiles/blogs/farmacia-online-donde-comprar-generico-indonol-25mg-sin-receta-al
http://summerschooldns.ning.com/profiles/blogs/farmacia-online-donde-comprar-generico-viagra-buen-precio-per
http://opencu.com/profiles/blogs/prometazina-comprar-en-una-farmacia-en-linea-sin-gastos-de-envio
http://empati.kim/index.php?qa=145849&qa_1=buy-super-kamagra-100-60mg-buy-super-kamagra-rapid-online
http://vocal-buzz.ning.com/profiles/blogs/lamprene-buy-without-prescription-buy-generic-lamprene-online
https://ikriate.me/blogs/92/374/metformin-glyburide-400-2-5mg-order-safely-how-can-i-purchase
http://whozwholive.ning.com/profiles/blogs/daclatasvir-60-mg-como-comprar-barato-uruguay
http://bricolocal.com/profiles/blogs/cheap-theo-24-sr-200-mg-order-online-best-online-theo-24-sr-store
http://shamrockballerz.ning.com/profiles/blogs/site-seguro-para-comprar-lizhuwei-gen-rico-na-internet
http://dmoney.ru/1354/commander-desvenlafaxine-achat-pristiq-pharmacie-ordonnance
http://ggwadvice.com//index.php?qa=7081&qa_1=farmacia-online-comprar-generico-dutasteride-receta-garantia
ordasskida
15 ноября 2018, 03:30
Столкнулись со сложной проблемой юридического плана, которую не можете решить самостоятельно? Обратитесь к профессионалам, работающим в сервисе «Юрист112» — здесь работают только настоящие специалисты, которые уже имели дело со всеми проблемами и точно знают, как грамотно их решить. Обо всех особенностях работы с юристами сервиса Вы можете ознакомиться на сайте https://юрист112.рф/ и проконсультироваться по интересующим Вас вопросам. Вам помогут решить жилищные или наследственные споры, а также взыскать задолженности.
просмотров:298520 | комметариев: 21

Оставить комментарий:    

Ваше имя:
 
Текст комментария:
 
+ 1 =