PHP Video Tutorial Part 4 [Arrays, Arrays Functions,Type Casting]

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)
Loading ... Loading ...

PHP Video Tutorial Part 4

Part 4: Documentation + Video Avi Format [Arrays, Arrays Functions,Type Casting]

Download Link :

Part 4  download

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:

Download Older One’s

  • 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.

arrays

Types of Array:

Arrays are of three types:

  1. Numeric array
  2. Associative array
  3. 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 :P :D

“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!

If you like it, then why not share with others and bookmark it :

  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • email
  • Internetmedia
  • LinkedIn
  • Live
  • MSN Reporter
  • MySpace
  • PDF
  • SphereIt
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • RSS
  • blogmarks
  • You know so many interesting information. You might be very wise. I like such people. Don’t stop writing.

  • thanks dear for commenting :) it will continue don’t worry…

  • Very useful idea

  • hi Lera,

    thanks for appreciation:)

    Stay Connected!
    Manan Saini

  • ???????????, ????? ????????????, ???????? ????????????,???????, ??????? ????????, ???? ?????, ???? ????? ???????.

  • I congratulate, magnificent idea and it is duly

You can follow any responses to this entry through the RSS 2.0 feed.