1 / 9

Arrays :

Arrays :. Specifying with Array () : - It takes a Certain number of comma – Seprated key => value pairs. Syntax : array( [ key => ] value ……. ). One Dimensional Arrays :. <? php $a [ ] =12 ; $a [ ] =32 ; $a [ ] =12.32 ; $a [ ] = “ viral Koradiya ”;

lucien
Download Presentation

Arrays :

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

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

  4. For Loop With Arrays : <?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 ]. ”<br>” ; } } ?>

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

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

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

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

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

More Related