Most Used Build-in Functions in PHP

1.) array() ; is used to create an array.

$arr1=array(1,2,3,4,5);  //created an array with 5 elements.
$arr2=array();           //created an empty array.
$arr3= array("name"=>"bill", "surname"=>"green", number=>45);      //created an array with key, value pair .

2.) count() : Returns the number of elements in array

$cars=array("apple","pear","quince");
echo count($cars);    //return 3 as an output.

3.) isset() : return True if the variable has been defined and a value assigned or return False if the variable is not defined.

$mail = $_POST['mail'];    //If the html form is not posted it gets NULL value
if (isset($mail)){
    echo "The mail was posted";
}else{
    echo "The mail was not posted";
}

4.) is_array(): Checks whether the variable is an array. Returns a Boolean value.

isset($variable)

$deg = array("a","b","c");
is_array($deg);        // return True as output.

5.) substr(string,start,length ):  It is used to return any number of characters in a string.

echo substr("Hello world",3)   // Counting from 0, it returns "lo world" as output.
echo substr("Hello world",1,7);  // If we count from 0, it returns 8 characters "lo worl" as output.