Functions



To show the use of a built in function I am going to use the array_filter() function. I will give the Apache an array of numbers to sift, where it will output the even numbers!



My built in array:


Array ( [1] => 22 [3] => 24 [5] => 26 [7] => 28 [9] => 30 )

Explanation
The numbers that print to the left (1,3,5,7,9) are the original positions that the numbers had in the array.


This is somewhat of a difficult built in function, so I will give another example below

Round function

3.4579

The rounded number is: 3

Here is my user defined function:

My name is Joe, I have brown hair and blue eyes.
Explanation

The function descriptionPerson that concatenates the input parameters into a string. When the function is called it outputs the sentence with the proper parameters.



PHP functions are essential for structuring your code in a clean, effecient, and reusable way.