Search This Blog

Monday, November 26, 2012

Array in PHP

In many Web applications, often we need a variable that can store multiple values at once in an organized manner, so that next time we can recover these values with ease and in a regular and well organized. No, not the database that I mean, as I was talking to a variable, and the database is not a variable. Why is this so important? Because in most cases we only need a store of value as well-organized, and the database is very expensive to do so. Think about connections, queries, and so on that will slow down the process when we use the database. This is where we need the array, a type of variable that can store multiple values at once even in different types of well-organized. Thus, in any programming language including PHP course you will always find an array as one of the types of variables. array is powerful.

What and Why

Arrays in PHP are a special type of variable, because the array we can access a set of values using a single variable name. The mechanism is arranged in the form of accessing the mapping of a set of values to a set of keys or indices. For example, the array variable $programer can map 1, 2 and 3 respectively to the "aaaaaa" "bbbbbb" and "cccccc', so it can be expressed as:

$programmer[1] = "aaaaaa";
$programmer[2] = "bbbbbb";
$programmer[3] = "cccccc";

where the expression 1, 2 and 3 is the index, while "aaaaaa" "bbbbbb" and "cccccc" are values.

$programmer_1 = "aaaaaa";
$programmer_2 = "bbbbbb";
$programmer_3 = "cccccc";
$cracker_1 = "dddddd";
$cracker_2 = "eeeeee";
$cracker_3 = "ffffff";

If we needed to print six of these data, it can be used in the following ways:

print "Name Programmer No 1: $programmer_1 <br>";
print "Name Programmer No 2: $programmer_2 <br>";
print "Name Programmer No 3: $programmer_3 <br>";
print "Name Cracker No 1: $cracker_1 <br>";
print "Name Cracker No 2: $cracker_2 <br>";
print "Name Cracker No 3: $cracker_3 <br>";

This method may be effective but unfortunately far from efficient. Why? because if the amount of data programmer and cracker on top of up to tens or even hundreds, then imagine how much you have to type the command. Not to mention, the webserver must do the parsing of hundreds of lines that will slow down the whole process. With an array, you can do better on the effective and efficient. 900 For example, a data programmer and cracker. How short, simple, but powerful. In addition, many PHP functions to manipulate arrays make the variable type is very helpful to our work in creating web applications. You simply perform the iteration as follows:

for ($k=0;$k<900;$k++)
    print "Nama hacker ke $k: $hacker[$k] <br>";
for ($k=0;$k<900;$k++)
    print "Nama cracker ke $k: $cracker[$k] <br>";

We will discuss some PHP functions to manipulate arrays in the next section.

Posted by: Admin
Easy Learn Computer, Updated at: 5:49 PM

11 komentar:

johan paterson said...
This comment has been removed by a blog administrator.
Alvin Payne said...
This comment has been removed by a blog administrator.
Online Fashion Shopping in India said...

You have some really good tips here for PHP functions to arrays and yes i will be looking for PHP functions to manipulate arrays. G8!

Computer And Technology said...

Nice post, thanks

Tahira Azher said...
This comment has been removed by a blog administrator.
Anuj kaushik said...

Your contents are more then help for me.
free web directory Canada

Sinelogix said...
This comment has been removed by a blog administrator.
Anonymous said...

Nice articles in your blog.
Must Be Learn

Anonymous said...

i like your post thanks for sharing keep it up.
Online Knowledge academy

ppc experts said...

PPC Expert For Tech Support |inbound calls for tech support, pop up calls for tech support Call at: +91 981-142-0083 ppc management experts ppc call provide by osiel web

Monika Gupta said...

Thanks for all your efforts that you have put in this.Very interesting information.I would like to do all the information

Computer Repairing Services In Delhi

Post a Comment

If you want to comment, We appreciate.
Please do not include a link, use the Link Exchange Facility