Array:
-Array in PHP is the type of data structure that store multiple elements of similar data types under a single variable
-Array creates a list of elements of similar types that can be accessed [] of the key.
-An array is created using array() function in PHP
[Array in PHP:
Array is a collection of similar data types]
Types of Array in PHP:
- Index or Numeric Array
- Associative Array
- Multidimensional Array
<?php $variable_name[n]=value; ?>
<!DOCTYPE html> <html> <head> <title>cwipedia.in</title> </head> <body> <?php $a[0]="Hi"; $a[1]="Hey"; echo "<br>Index Array<br>"; echo $a[0],"<br/>",$a[1]; ?> </body> </html>
<?php $variable_name=$array(Keyname => value) ?>
<!DOCTYPE html> <html> <head> <title>cwipedia.in</title> </head> <body> <?php $c=array("CSE"=>"101","CIVIL"=>"102"); echo "<br>Associative Array"; echo "<br>CSE=",$c["CSE"],"<br>CIVIL=",$c["CIVIL"]; ?> </body> </html>
?php $variable_name=array( array(element....), array(element....), . . . ) ?>
<!DOCTYPE html> <html> <head> <title>cwipedia.in</title> </head> <body> <?php $person=array( array("Name"=>"Shivam", "Email"=>"shivam@gmail.com"), array("Name"=>"XYZ", "Email"=>"xyz@gmail.com") ); echo "<br>Multidiamentional Array"; echo "<br>Shivam's Email Id:- ",$person[0]["Email"]; ?> </body> </html>

Comments
Post a Comment
If you have any query, please let us know