Monday, March 4, 2019

PHP - Functions and Arrays

PHP has a wide range of power in the real-time world comes through a lot of
PHP Function and PHP has a built-in function. In PHP we can able to
create our own functions with the help of PHP Functions


PHP Functions:
A Function is a set of program or statements are used frequently in a program.
It won’t execute at the run time or page loads. A Function in PHP Course in Chennai
will only execute when the particular function call.


Basic Syntax of User Defined Function:
function funName() {
 // codes;
}


Note:
1.A function is Not Case Sensitive


Function Arguments:
1. Arguments are very important in PHP Training in Chennai Function because it playing
a major role in passing the particular functions Information.
2. Arguments are treated as a variable. Arguments are given the function name.
we can add many arguments in the function name and the added
arguments are separated by a comma.


Function Default Arguments:
If a Function is called without any arguments then it can declare as default arguments.
whenever the arguments are passed or called
without any variable name are called as Default Arguments.
If a function wants to return a value then we can go for return statements.
Return statements are created for this purpose only.


PHP Arrays:
1. A PHP Training Institute in Chennai Array is able to store multiple values in a single value.
2. Array plays a major role by storing the enlarged amount of values in a single variable.
3.with the help of array, we can store numerous amount of data or values.


How To Declare an Array:
array();


Types of Array:
Array are classified into three types, they are:
1.Indexed Array
2.Associative Array
3.Multidimensional Array


INDEXED ARRAY:
The Indexed array can be declared or create in two ways, they are:
1. It can be assigned spontaneously
2. It can be assigned manually or non-automatic.


How To Find the length of the Array:
By using the count() function we can able to find the length of the array and it also used
to return the number of the portion(elements) or length.PHP Course in Chennai


ASSOCIATIVE ARRAY:
1. Associative Array is assigned with a key.
2.with the use of the key, it can assign the value.


How we can Sort the Array?
With the help of Sorting Array Functions, we can able to sort the array. the segment
of an array can be sort Best PHP Training in Chennai in descending or ascending
order or numerical or alphabetical order.


Sort Array - Ascending Order:
sort() function is used to sort an array in Ascending order. through these function,
it is very easy to sort an array in ascending order.
Sort Array - Descending Order:
rsort() function is used to sort array in Descending order.through the function it is very easy to
sort an array in descending order.PHP Training in chennai


Sort Associative Array - Ascending order:
asort() function is used to sort the associative  array in ascending order according
to their value.


Sort Associative Array - Ascending order:
ksort() function is used to sort the associative array in ascending order according to their key.


Sort Associative Array - Descending order:
arsort() function is used to sort the associative  array in descending order according to their value.


Sort Associative Array - Descending order:
krsort() function is used to sort the associative array in descending order
according to their key.PHP Training Institute in chennai

No comments:

Post a Comment