PHP for Beginners – Part 3


Hey Folks! In this part of the tutorial we will be seeing how to create functions,  play with single and multidimensional arrays and String related functions. These are the backbone of any programming language. Almost 80% of time when we code we will be needing them. All of you young learners put full effort in this section.


Definition: Function is a block of code used for perform a specific task.

Why and When we use function? Let’s take an example where you need to wake up early and you tell your mother/father/friend to wake you up early in the morning. So as being asked they wake you up that day. But let’s take a case where you have to wake up early on daily basis. Ask them for the favor, I guess you better know the results. So In that case you set an alarm in your phone or watch. So that is what function is all about, to do a task repeatedly without coding it over and over.

See the syntax for writing a function.

Have a look at the example below.

By default PHP provides rich sets of function that makes our lives easier. Some of them are listed below, to search for a specific function visit the PHP site.

Tips: Whenever you have to write a code with more than 10 lines, or a common code that will be needing more than once place the code under a function.


Definition: You already know about variable. Array is nothing but a sequence of variable of similar or dissimilar type.

Explanation: You can say, Array is a container that can hold many variables. The starting index is zero and ends with (n-1). Associative array is marked with key and value. Remember a key must be integer or string.

Multi Dimension Arrays

There are cases where we have an array that contain an array, In that case we called it multi dimension array or array of arrays.

Commonly used array functions. See all functions here


String is a series of character. Same as arrays it also has got index from which we can get the value of that particular index. Look at the example below you will get to know what I am talking about.

Most commonly used string function. See all functions here

and thats all for this Tutorial. 🙂

Was this article/content helpful?
Thanks! Your feedback helps us to improve

Leave a Reply

Your email address will not be published. Required fields are marked *