PHP Articles

Page 2 of 81

PHP Program for Binary to Decimal Conversion

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 22-Jan-2025 6K+ Views

Binary to decimal conversion is the process of converting a binary number i.e., number represented using only two bits 0s and 1s into its equivalent decimal number i.e., base 10 form. In this article, we are going to learn how we can convert the binary form of a number to a decimal form of a number in PHP using different approaches. How to convert Binary to Decimal? Binary numbers (base-2) are composed of only 0s and 1s bits which are used by machines, Decimal numbers are base-10 form numbers that humans use. For converting a binary number to a decimal, ...

Read More

PHP Program to Count Vowels in a String

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 15-Jan-2025 8K+ Views

A string is a sequence of characters, including alphabets, numbers, and symbols. In this tutorial, we are going to learn how we can count the number of vowels in a given string in PHP using different approaches. Vowels in English are a, e, i, o, u, and they can be either uppercase or lowercase. What is a Vowel? Vowels are alphabetic characters that represent specific speech sounds.There are a total of five vowels, both uppercase and lowercase in the English language: a, e, i, o, u Example 1 Input: string = "Tutoriaspoint" ...

Read More

How to Install phpMyAdmin with Nginx on Ubuntu?

Mead Naji
Mead Naji
Updated on 31-Dec-2024 225 Views

When you try to build a website for production or just start learning web development, you need a server to make your web application accessible from the browser to other users, either to use it or test its functionality. The web server is an interesting part of any web application that involves backend tasks. Nginx is a better choice for a server to serve websites. It is known for its efficiency and capacity to handle large traffic. Perhaps as a server, Nginx can also work as a reverse proxy and load balancer. The pronunciation of the word "Nginx" is like ...

Read More

How to Check If Two Arrays are Equal in PHP?

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 27-Dec-2024 5K+ Views

Problem Description Sometimes we need to compare two arrays in PHP to check if they are equal. Talking about equality, it means that the arrays have the same elements, in the same order, or even that their data types match. In this article, we will discuss how we can check if two arrays are equal or not in PHP. The following are different approaches to check If two arrays are equal in PHP - Brute Force Approach Using the == Operator Using array_diff() Method ...

Read More

PHP program to find the perimeter of rectangle

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 10-Dec-2024 7K+ Views

Problem Description Given the length and breadth of a rectangle, we need to implement a PHP program to find the perimeter. A rectangle is a closed two-dimensional figure having 4 sides. The opposite sides are equal and parallel. The angle made by the adjacent side is equal to 90 degrees. The perimeter is the sum of all sides; in other words, the perimeter is two times the sum of length and breadth. In this tutorial, we are going to learn how we can find the perimeter of a given rectangle in PHP using different approaches. Formula of Perimeter of ...

Read More

PHP Program to Check if a Number is an Armstrong Number

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 03-Dec-2024 5K+ Views

Armstrong Number Armstrong number is a number in which the sum of its digits raised to the power of the number of digits is equal to the number itself. In this article, we are going to discuss how we can check if a given number is Armstrong number or not. Examples Let's understand Armstrong's Number with the help of some input-output examples. Input 9474 Output Yes Explanation This is a four digit-number. The digit in this number are 9, 4, 7 and 4. 9474 = 94 + 44 + 74 + 44= 6561 + 256 + 2401 + 256= ...

Read More

How to get selected option value in PHP

PHP
NIKI
NIKI
Updated on 22-Nov-2024 1K+ Views

In this article, we will see how to get selected option values in PHP, with necessary examples. What is "option value" in PHP? Drop-down menus are created by using the and . PHP allows users to select one or more options from a list. Syntax Below is the syntax of the Option Value in PHP − Text Label-1 Text Label-2 . . . The characteristics related with the tag are − Multiple: This is used to choose multiple choices from a list. ...

Read More

How to Add Elements to the End of an Array in PHP

PHP
AYUSH MISHRA
AYUSH MISHRA
Updated on 01-Nov-2024 9K+ Views

Arrays are linear data structures used to handle data in programming. Sometimes while dealing with arrays we need to add new elements to an existing array.In this article, we will discuss several methods to add elements to the end of an array in PHP, complete with code examples, outputs, and an analysis of the time and space complexity of each approach. Following are different approaches to adding elements to an array − Using square brackets [] We add an element to the end of an array in PHP is by using square brackets []. This syntax is only suitable when ...

Read More

Run a Python program from PHP

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 10-Sep-2024 7K+ Views

In PHP, the 'exec()' or 'shell_exec’ function can be used. It can be executed via the shell and the result can be returned as a string. It returns an error if NULL is passed from the command line or returns no output at all. 'exec()' Function The exec function is used for executing commands in the shell and command line of an external program and optinally capture the last line of the output. Syntax exec(string $command, array &$output = null, int &$return_var = null); 'shell_exec()' Function The shell_exec is similiar to exec but it captures and return the ...

Read More

How can I force PHP to use strings for array keys?

PHP
Timpol
Timpol
Updated on 16-Aug-2024 320 Views

To force PHP to use strings for array keys is quite easy, as in PHP array keys are automatically stored as integers if the array elements are numbers. If they are not numbers then it will cast to strings. Forcing PHP to Use strings for Array Keys Following are the ways to force PHP to use strings for array Keys Using php array() function Using json_encode() function Using php array() Function If you use the array() function and keep the first key in quotes it will take other keys as a string does not matter if you are ...

Read More
Showing 11–20 of 801 articles
« Prev 1 2 3 4 5 81 Next »
Advertisements