Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Specifying with Array () : - It takes a Certain number of comma – Seprated key => value pairs.  Syntax : array( [ key => ] value ……. )

Similar presentations


Presentation on theme: " Specifying with Array () : - It takes a Certain number of comma – Seprated key => value pairs.  Syntax : array( [ key => ] value ……. )"— Presentation transcript:

1  Specifying with Array () : - It takes a Certain number of comma – Seprated key => value pairs.  Syntax : array( [ key => ] value ……. )

2 <?php $a [ ] =12 ; $a [ ] =32 ; $a [ ] =12.32 ; $a [ ] = “ viral Koradiya”; Print $a [ 0 ].” ” ; Print $a [ 1 ].” ” ; Print $a [ 2 ].” ” ; Print $a [ 3 ].” ” ; ?>

3 <?php $a [ 0 ] [ 0 ] =12 ; $a [ 0 ] [ 1 ] =32 ; $a [ 1 ] [ 0 ] =12.32 ; $a [ 1 ] [ 1 ] = “ viral Koradiya”; Print “$a [ 0 ] [ 0 ]”. “ &nbsp ;”.“$a [ 0 ] [ 1 ]”.” ” Print “ ’ Print “$a [ 1 ] [ 0 ]”.” ” Print “$a [ 1 ] [ 1 ] ;” ?>

4 <?php $a [ 0 ] [ 0 ] = 12 ; $a [ 0 ] [ 1 ] = 32 ; $a [ 1 ] [ 0 ] = 12.32 ; $a [ 1 ] [ 1 ] = “ viral ”; For ($i = 0 ; $i <= 1 ; $i++ ) { for($j = 0 ; $j <= 2 ; $j++ ) { print $a [ $i ] [ $j ]. ” ” ; } ?>

5 <?php $ar = array ( 10,110,210.10, “VIRAL” ); Foreach( $ar as $new1 => $new2) { print “Keys [“.$new1.”]”. “ value ”.$new2. “ ”; } ?>

6 Example 1 : $ages = array(“Viral “ => 10, ”Meet” => 20, “Swat” =>30 );

7 Example 2 : $ages [ ‘viral’ ] = “20 “; $ages [ ‘vijay’ ] = “25 “; $ages [ ‘Meet’ ] = “30 “; ~> Id Keys can be used in a Script :

8 Example 3 : <?php $ages [ ‘viral’ ] = “20 “; $ages [ ‘vijay’ ] = “25 “; $ages [ ‘Meet’ ] = “30 “; Echo “Viral Age is :”.$ages[ ‘Viral ‘ ]. “Years is old. “ ?>

9 Example 4 : <?php $ar =array(5,”One”=>34, “Two”=>50, 70.62, “Hello”=>”viral”); Foreach( $ar as $new1 => $new2 ) { print $new1.”=>”. $new2.” ”; } ?>


Download ppt " Specifying with Array () : - It takes a Certain number of comma – Seprated key => value pairs.  Syntax : array( [ key => ] value ……. )"

Similar presentations


Ads by Google