• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Saturday, July 21, 2012

ARRAY IN PHP


Hi.. welcome in my page… in “We are Knowledge”. I hope you getting it.

Now.. I want to giving you knowledge PHP abour “ARRAY”.

You know array .. ? yes. That’s right array is variable which allows more than one element. Or Arrat is data set in one variable.

Ok.. let’s do coding..

Syntax :

Array (element)

Or

variable= array(element1, element2, element3, element4, element5, …, element n)


Example1 :
you can copy this coding

<?php
$age = array(14, 16, 18, 20, 22, 24, 26, 28);
echo $age[6];
?>


Next paste in your notepad… and don’t forget save as type = ”php”.
If it is for working you must active “XAMPP” is “APACHE”.

To result is:
26

Because

$age 0 = 14
$age 1 = 16
$age 2 = 18
$age 3 = 20
$age 4 = 22


Example 2:

You can copy this coding. Or you type in your own in oeder to you more easly to learn.

<?php
$wak = array(we, are, knowledge, is, blogging, the, coolest, you, must, visit);
for ($a = 0; $a <= 11; $a++)
{
echo $wak[$a]."<br>";
}
?>


And if you done copy, paste in your notepasd or notepad++. And don’t forget save as type “PHP”
If it is for working you must active “XAMPP” is “APACHE”.

To result :
we
are
knowledge
is
blogging
the
coolest
you
must
visit


Example 3:

You can copy this coding

<?php
$wak = array("we","are","
knowledge","is","blogging","the", "coolest");
list($a, $b, $c, $d, $e, $f, $g) =
$wak;
echo $a."<br>";
echo $b."<br>";
echo $c."<br>";
echo $d."<br>";
echo $e."<br>";
echo $f."<br>";
echo $g."<br>";
?>


If it is.. save with saveas type “PHP”
And working..

To result is :
we
are
knowledge
is
blogging
the
coolest


Ok.. just it..

I hope you understanding with my tutorial.

Thanks for visit… and thanks for visitors

See you later.

No comments:

Post a Comment