AmitDiwan has Published 10744 Articles

PHP program to compare float values

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:45:05

151 Views

To compare float values in PHP, the code is as follows −Example Live DemoOutputThe values are not sameThree values are defined that are floating point numbers. The absolute values of these numbers are compared and relevant message is displayed on the console.

Select three random records with a fixed number of characters for each column value in MySQL

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:43:49

112 Views

For this, you can use CHAR_LENGTH(). Use RAND() for random records. Let us first create a table −mysql> create table DemoTable (Subject text); Query OK, 0 rows affected (0.61 sec)ExampleInsert some records in the table using insert command −mysql> insert into DemoTable values('C'); Query OK, 1 row affected (0.16 sec) ... Read More

PHP program to sort dates given in the form of an array

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:43:22

165 Views

To sort dates given in the form of an array in PHP, the code is as follows −Example Live DemoOutputThe dates in sorted order is Array (    [0] => 2090-12-06    [1] => 2020-09-23    [2] => 2002-09-11    [3] => 2009-30-11 )A function named ‘compare_dates’ takes two time formats ... Read More

PHP program to compare two dates

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:41:52

239 Views

To compare two dates in PHP, the code is as follows −Example Live DemoOutput2020-11-22 is later than 2011-11-22Two dates of ‘DateTime’ format are generated and checked to see which one is sooner or later. If the first date is later, relevant message is printed on the console. Otherwise, a message indicating ... Read More

PHP program to find number of days in every week between two given date ranges

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:40:19

631 Views

To find number of days in every week between two given date ranges in PHP, the code is as follows −Example Live DemoOutputThe number of days between the given range isArray (    [Monday] => 5    [Tuesday] => 5    [Wednesday] => 5    [Thursday] => 5    [Friday] => ... Read More

PHP program to find the total number of date between any two given dates

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:38:28

215 Views

The ‘date_diff’ function can be used to get the difference between two dates. It is a built-in function that returns a DateInterval object if a specific number of days has been found, and returns False if the days is not found.Example Live DemoOutputThe day difference is: +60 daysTwo dates are defined ... Read More

PHP program to print continuous character pattern triangle

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:37:21

430 Views

To print continuous character pattern triangle in PHP, the code is as follows −Example Live DemoOutputA B C D E F G H I J K L M N O P Q R S T UThis is similar to generating a star or a number pattern, the only difference being, continuous ... Read More

PHP program to print continuous numbers in the form of triangle

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:35:25

300 Views

To print continuous numbers in the form of triangle in PHP, the code is as follows −Elements Live DemoOutput1 2 3 4 5 6 7 8 9 10This is similar to generating a star or a number pattern, the only difference being, continuous numbers are generated instead of stars or repeated ... Read More

PHP program to print the number pattern

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:34:08

2K+ Views

To print the number pattern in PHP, the code is as follows −Example Live DemoOutput1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6This is similar to generating a star pattern, the only difference being, numbers are generated instead of ... Read More

PHP program to print a pattern of pyramid

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:32:21

2K+ Views

Let us see an example to print a pattern of pyramid in PHP −Example Live DemoOutput         *         * *        * * *       * * * *      * * * * *     * * * ... Read More

Advertisements