Is_array() Function in PHP29 Aug 2024 | 4 min read Array - arrays is a specific data type that allows us to store numerous components of a single type of data under a specific variable, this method helps us to reduce the time and energy of creating several variables for every data. We can access every element of an array using an index, for example if we need to store the salaries of 5 different employees, instead of creating 5 variables for every employee we can easily create an array salary with the salaries of all employees inside a single variable salary. In this case creating 5 variables is still a doable task but what if we have to store the salary of 100 or even 1000 employees, in such cases arrays are the best preference. Is _ array ( ) - is another inbuilt function of PHP which is used to evaluate whether a defined variable is an array or a different variable. Syntax: is_array function accepts a single parameter, $ variable name is the nave of the declared variable which we have to check. The is_array () function returns Boolean value i.e. if the variable is an array it will return TRUE else it will return FALSE. Example Output: good morning is not an array Array ( [0] => cyan [1] => magenta [2] => yellow ) is an array Array ( [doctor] => 35LPA [engineer] => 27LPA [accountant] => 20LPA ) is an array cyan, magenta, yellow is not an array In this program, we have declared multiple variables with different data and with the if else statement we have deduced the output whether the declared variable contains an array or not, we have used is_array function to check whether the declared data is array or not. Example: Output: Array ( [0] => A [1] => B [2] => C ) A B C is an array 29.99 is not a array value. 42 is not a array value. abc is not a array value. In this program, we have declared multiple variables with different data and with the if else statement we have deduced the output whether the declared variable contains an array or not, we have used is_array function to check whether the declared data is array or not. |
How to count all elements in an array in PHP? To count all the elements in an array, PHP offers count() and sizeof() functions. The count() and sizeof() both functions are used to count all elements in an array and return 0 for a variable that has...
1 min read
PHP and C have most of the same syntax rules. PHP is a language for server-side scripting. Text files with the ".php" suffix are used to store PHP code. Basic Structure of a PHP Script PHP scripts are included within the HTML, and they have to begin...
6 min read
PHP Imagecreate( ) Function Image create ( ) function is another inbuilt PHP function mainly used to create a new image. The function returns the given image in a specific size. We need to define the width and height of the required image. Instead of the image...
4 min read
Exception handling is a powerful mechanism of PHP, which is used to handle runtime errors (runtime errors are called exceptions). So that the normal flow of the application can be maintained. The main purpose of using exception handling is to maintain the normal execution of the application. What...
4 min read
For web applications to manage data manipulation with ease, CRUD operations are necessary. PHP and MySQL work together to make CRUD operations simple and database management effective. The CRUD operations will be covered in this article, along with instructions for configuring the MySQL database connection...
5 min read
Imagecolortransparent() function is another inbuilt PHP function mainly used to distinguish a color as transparent. It is used to customize the color of the image to be transparent. It returns the identifier of the new transparent color, where if there is no transparent element defined on...
5 min read
PHP language provides a multiple GMP function to handle and operate on numeric data. The GMP function gmp_scan0() shows the "scan to 0" bit and number. Here, we can find the position of the "0" value in the input base number. The number scans to 0...
4 min read
The PHP GMP import function converts string values into a binary value. We can operate the mathematical function of string data using the gmp_import() function. Syntax The following syntax shows the PHP GMP import function. string gmp_import (GMP $numbers, int $num_size, int $option_nums); Parameters As shown above syntax and explained below,...
4 min read
Imagestring( ) function is another inbuilt PHP function mainly used to draw a horizontal string. The function works using the x and y-axis, used to set coordinates for the starting point from where the picture has to be drawn. The origin coordinates ( 0, 0 )...
4 min read
? The interface is another property of PHP that enables the developer to build a program without any complex methods. It inherits the same public method that a class holds. Due to these properties, an interface can define methods. Still, we cannot define the method in that...
5 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India