PHP Video Tutorial Part 4 [Arrays, Arrays Functions,Type Casting]
PHP Video Tutorial Part 4
Part 4: Documentation + Video Avi Format [Arrays, Arrays Functions,Type Casting]
Download Link :
Size: 1.65 MB After Extract 420 MB
And Also you can check all older and Incoming tutorials here :
Tutorial Links
“Documentation“
Hello Friends,
Welcome To PHP Tutorial Part 4
Topic Covered: Arrays, and its Function and Type Casting
Well I think you read my first tutorial PHP part 1, 2, 3 if not then kindly download from here:
- Go to PHP folder and download PHP Part 1, 2 and 3
________________________________________________________________________________________________
Today we will discuss arrays, and its function and Type casting.
So let’s see the simple definition of array.

Types of Array:
Arrays are of three types:
- Numeric array
- Associative array
- Multi-dimension array
Let’s start with first i.e. Numeric.
<?php
$array1 = array( 0,1,2,3,4,5); // check the syntax ..
echo $array1[1]; // lets see which value it will display
?>
You see it will display 2nd value it mean array start from 0. These 0, 1, 2, 3, 4, 5 all call pockets or ID key.
Now come to 2nd type i.e. Associative Array. In this case each pocket i.e. id key have some particular value. Before going to 2nd type let me show how to display string in type 1.
<?php
$array2 = array( 2, “manan”, 3 ,”OUG”); // u see ” ” double quotes for string.
echo $array2[1]; //let’s suppose I want to display string manan
?>
You see for displaying string. Now come to 2nd type Associative.
<?php
$array3 = array( “manan” =>14 , “oug” => 13, “count”=> 10000 ); /*see string in quotes and numeric as it . Concentrate on the i.e. equal to sign and greater than sign syntax of this type
*/
echo “<br/>”;
echo $array3["oug"];
?>
See the output, it will display the value of oug i.e is associative.
Now come to 3rd type i.e. multi dimension Array. Multi dimension array mean array contain 1 or more array. In this each element in the main array can also be array i.e. array inside array. Let’s c in the program it will be more clear.
<?php
$array4 = array(
// look care full it’s complicated. Now we make array inside arary
“websites”=> array(
“orkut”,
“google”,
“logicmatters” ),
// create one more
![]()
![]()
“OUG” => array(
“owner”,
“moderators”,
“members”
)
// now how to display on screen its output
);
echo $array4['websites'][1];
?>
Now come to “Type Casting “
Well type Casting mean convert one data type into another. Now we see how we find which variable comes under which data type whether is integer or string etc.
Program is self explanatory. Let me tell you about this. Let’s suppose if we have one variable contains integers and string and we try to add in that variable which only contains integers then only integer values of first variable will add in to 2nd variable.
Let’s take a look at program var1 has integer + string and var2 having var1+ integer value. So output remains integer only because we add integer in var1.
<?php
$var1= “3 Nothing is impossible”; // 3 variable
$var2= $var1+27;
echo $var2; // answer always in terms of var2 i.e. Variable adds not string. check output
// See the o/p 27+3 =30
echo gettype($var1) .”<br/>”; // command for view which type of variable
echo ge ttype($var2) .”<br/>”; // command for view which type of variable
settype ($var2,”string”) ; // command for change the type of variable
echo gettype($var2) .”<br/>”; // command for view which type of variable
// See the difference now type changed
$var3 =(int) $var1; // another method to change the type of variable
echo gettype($var3) .”<br/>”; // command for view which type of variable
//Now again change it to integer type.
?>
Hope you enjoying the tutorial.
If any problems mail me at: encarta.mann@gmail.com
Thanks for reading this documentation. Continue in Next Edition ….
Thanks,
LM Team!






GarykPatton
16 Jun, 2009
You know so many interesting information. You might be very wise. I like such people. Don’t stop writing.
Root Admin
17 Jun, 2009
thanks dear for commenting
it will continue don’t worry…
LeraJenkins
24 Jun, 2009
Very useful idea
Root_Admin
26 Jun, 2009
hi Lera,
thanks for appreciation:)
Stay Connected!
Manan Saini
vnkitecom
1 Jul, 2009
???????????, ????? ????????????, ???????? ????????????,???????, ??????? ????????, ???? ?????, ???? ????? ???????.
PeterMontee
3 Jul, 2009
I congratulate, magnificent idea and it is duly