By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
LahbabiGuideLahbabiGuide
  • الرئيسية
  • مزيج مِن أفكاري
    • مقالاتي
    • قصص قصيرة
    • سيناريوهات أفلام قصيرة
    • نصوص مسرحية قصيرة
  • أفكار المشاريع
  • قصص النجاح
  • أخبار تقنية
  • القرأن الكريم
Search
  • Advertise
© 2022 Zakariaelahbabi.com . Company. All Rights Reserved.
Reading: Generate Random Numbers In PHP | Numbers In Sort By Order
Share
Notification Show More
Latest News
bootstrap-clean-buttons-with-hover-effect-|-plain-button-ui-kit
Bootstrap Clean Buttons With Hover Effect | Plain Button UI Kit
Bootstrap
bootstrap-datatable-with-sort,-pagination,-and-search-|-sorting-data-table
Bootstrap Datatable With Sort, Pagination, and Search | Sorting Data Table
Bootstrap
upload-image-in-php-with-mysql-database-|-web-dev-trick
Upload Image In PHP With MySQL Database | Web Dev Trick
PHP
bootstrap-tooltip-progress-bar-animation-|-percentage-values-in-tooltip
Bootstrap Tooltip Progress Bar Animation | Percentage Values in Tooltip
Bootstrap
php-age-calculator-program-|-calculate-age-in-php
PHP Age Calculator Program | Calculate Age In PHP
PHP
Aa
LahbabiGuideLahbabiGuide
Aa
  • مزيج مِن أفكاري
  • أخبار تقنية
  • تطوير الويب
  • أفكار المشاريع
Search
  • Home
    • Home 1
    • Default Home 2
    • Default Home 3
    • Default Home 4
    • Default Home 5
  • Categories
    • تطوير الويب
    • أخبار تقنية
    • أفكار المشاريع
    • مزيج مِن أفكاري
    • قصص النجاح
  • Bookmarks
  • More Foxiz
    • Sitemap
Follow US
  • Advertise
© 2022 Foxiz News Network. Ruby Design Company. All Rights Reserved.
generate-random-numbers-in-php-|-numbers-in-sort-by-order
LahbabiGuide > تطوير الويب > PHP > Generate Random Numbers In PHP | Numbers In Sort By Order
PHP

Generate Random Numbers In PHP | Numbers In Sort By Order

admin
Last updated: 2023/03/11 at 7:37 صباحًا
By admin
Share
5 Min Read
SHARE

I saw many guys in the different group who was asking for How To Generate Random Numbers In PHP?  That’s why today I will cover this topic and give source code of a program in this topic. First of all, I want to say that I am not a PHP expert. I am just learning It. In the future, I will learn other backed languages like Node JS.

Contents
Preview Of Random Numbers Generator Program In Sort By OrderGenerate Random Numbers In PHP Programs Source Code

Today I am sharing a program about create random numbers by sort order in PHP.  There I am covering two topics. First, create random number in PHP. Second I am printing those random number in sort by order. Now, if are you thinking this is an advanced program, Then I want to say you that this is a very small program.

This program is fully dynamic, You have to code one time and this will print 25 numbers using a loop.  This program is also a little bit stylish. And at the same time, it looks stylish also. Because I used CSS but very less. Let’s take the preview of this program first.

Preview Of Random Numbers Generator Program In Sort By Order

First, Take a look at this PHP program. In other words, see how this program looks visually.

https://webdevtrick.com/wp-content/uploads/php-generate-random-number.mp4

Now you can clearly see the function of this automatically generating number. You can change this program as you want after understanding the code.

You May Also Like:

  • Image Upload In PHP
  • Registration System PHP
  • PHP MySQL Crud Program

Generate Random Numbers In PHP Programs Source Code

Before sharing source code, I want to say about this program. Basically, this program is created using the PHP rand(min,max); function. The rand() function generates a random integer ( know more about PHP rand ). Then I printed all numbers using the echo "" command. I also use a PHP loop for to print multi times.

You have to create 2 files for this program. One for PHP, & another for CSS. Just follow steps:

phprandom.php

Create a PHP file named ‘phprandom.php‘ and put these codes give here below. If you want to change this file name, Then you also have to change the file name in the forms action="" section.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

<!DOCTYPE html>

<!— Code By Webdevtrick ( https://webdevtrick.com ) –>

<html>

<head>

<meta charset=“utf-8”>

<title>Generate Random Number | Webdevtrick.com</title>

<link href=“style.css” rel=“stylesheet”>

</head>

<body>

<h1>Generate Random Number By Sort Order</h1>

<form method=“post” action=“phprandom.php”>

<input name=“random” type=“submit” value=“Generate” />

</form>

<!— PHP Start ( https://webdevtrick.com ) –>

if(isset($_POST[‘random’])){

echo ‘

‘;

    $min=1;

    $max=100;

$arrayNumersx = array();

    for ($i=1; $i <= 50 ; $i++){

      $numero = rand($min,$max);

  if (in_array($numero,$arrayNumersx)) {

       $i—;

       }else{

       $arrayNumersx[] = $numero;

       }

    }

sort($arrayNumersx);

$tamanhoArray = count($arrayNumersx);

for($y = 0; $y < $tamanhoArray; $y++){

   echo “

“, ($arrayNumersx[$y]), “

“ ;

}

echo ‘

‘;

}

?>

</body>

</html>

style.css

Now create a CSS file named ‘style.css‘ for giving style to this program. & Put these lines of codes.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

/* Code By Webdevtrick ( https://webdevtrick.com ) */

body {

background: #333;

}

h1{

text-align: center;

color: white;

text-transform: uppercase;

font-size: 3em;

font-family: “helvetica”;

}

.numbers{

display: flex;

flex-direction: row;

   flex-wrap: wrap;

   background: #333;

}

.numbers div {

background: #2ab1ce;

padding: 5px;

margin: 2px;

justify-content: space-around;

color: #fff;

font-size: 4em;

width: 9%;

text-align: center

}

form{

display: flex;

justify-content: center;

margin-bottom: 50px;

}

form input{

background: #2ab1ce;

color: #fff;

font-size: 2em;

}

That’s It. Now you have successfully created generate random numbers in PHP program with sort by order. If you have any doubt or question comment down below.

Thanks For Visiting, Keep Visiting.

You Might Also Like

Bootstrap Clean Buttons With Hover Effect | Plain Button UI Kit

Bootstrap Datatable With Sort, Pagination, and Search | Sorting Data Table

Upload Image In PHP With MySQL Database | Web Dev Trick

PHP Age Calculator Program | Calculate Age In PHP

Bootstrap Tooltip Progress Bar Animation | Percentage Values in Tooltip

TAGGED: CSS, css tips, PHP, php source code, php tutorial, random numbers, source code, Web Development
admin مارس 11, 2023
Share this Article
Facebook Twitter Pinterest Whatsapp Whatsapp LinkedIn Tumblr Reddit VKontakte Telegram Email Copy Link Print
Previous Article new-years-countdown-timer-with-jquery-and-bootstrap-layout-|-time-left New Years Countdown Timer With jQuery and Bootstrap Layout | Time Left
Next Article php-age-calculator-program-|-calculate-age-in-php PHP Age Calculator Program | Calculate Age In PHP
Leave a comment Leave a comment

اترك تعليقاً إلغاء الرد

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *

Stay Connected

235.3k Followers Like
69.1k Followers Follow
11.6k Followers Pin
56.4k Followers Follow
136k Subscribers Subscribe
4.4k Followers Follow
- Advertisement -
Ad imageAd image

Latest News

bootstrap-clean-buttons-with-hover-effect-|-plain-button-ui-kit
Bootstrap Clean Buttons With Hover Effect | Plain Button UI Kit
Bootstrap مارس 11, 2023
bootstrap-datatable-with-sort,-pagination,-and-search-|-sorting-data-table
Bootstrap Datatable With Sort, Pagination, and Search | Sorting Data Table
Bootstrap مارس 11, 2023
upload-image-in-php-with-mysql-database-|-web-dev-trick
Upload Image In PHP With MySQL Database | Web Dev Trick
PHP مارس 11, 2023
bootstrap-tooltip-progress-bar-animation-|-percentage-values-in-tooltip
Bootstrap Tooltip Progress Bar Animation | Percentage Values in Tooltip
Bootstrap مارس 11, 2023
//

We influence 20 million users and is the number one business and technology news network on the planet

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

[mc4wp_form id=”847″]

LahbabiGuideLahbabiGuide
Follow US

© 2022 Foxiz News Network. Ruby Design Company. All Rights Reserved.

Join Us!

Subscribe to our newsletter and never miss our latest news, podcasts etc..

[mc4wp_form]
Zero spam, Unsubscribe at any time.

Removed from reading list

Undo
Welcome Back!

Sign in to your account

Lost your password?